当前位置: 首页>>代码示例>>C#>>正文


C# QueryBuilder.getDatabaseObject方法代码示例

本文整理汇总了C#中QueryBuilder.getDatabaseObject方法的典型用法代码示例。如果您正苦于以下问题:C# QueryBuilder.getDatabaseObject方法的具体用法?C# QueryBuilder.getDatabaseObject怎么用?C# QueryBuilder.getDatabaseObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder.getDatabaseObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: selectQueryHandler


//.........这里部分代码省略.........

                        }
                        }
                        else
                        {
                            joinList.Add(paramString);
                        }

                        foreach (string tmpstr in joinList)
                        {
                            paramString = tmpstr.Substring("inner join".Length+1);
                            // inner join anothertable on sjlieglij=sliejgil
                            string lTmp = paramString.Substring(0, paramString.IndexOf(" on "));
                            if (lTmp.IndexOf(' ') != -1)
                            {
                                tableAlias = lTmp.Substring(lTmp.IndexOf(' ')).Trim();
                                tablename = lTmp.Substring(0, lTmp.IndexOf(' ')).Trim();
                            }
                            else
                                tablename = lTmp.Trim();

                            lTmp = paramString.Substring(paramString.IndexOf(" on") + " on".Length + 1);
                            string srcTable = ""; string dstTable = "";
                            string srcField = ""; string dstField = "";

                            srcTable = lTmp.Substring(0, lTmp.IndexOf('='));
                            dstTable = lTmp.Substring(lTmp.IndexOf('=') + 1);
                            if (srcTable.IndexOf('.') > 0)
                            {
                                // Assume specifed table.
                                srcField = srcTable.Substring(srcTable.IndexOf(".") + 1);
                                srcTable = srcTable.Substring(0, srcTable.IndexOf("."));
                            }
                            if (dstTable.IndexOf('.') > 0)
                            {
                                // Assume specifed table.
                                dstField = dstTable.Substring(dstTable.IndexOf(".") + 1);
                                dstTable = dstTable.Substring(0, dstTable.IndexOf("."));
                            }

                            newQuery.addSource(new ATable(tablename, tableAlias), ABSTRACTSOURCEBINDTYPES.INNERJOIN, ((QueryBuilder.SOURCEBINDING)newQuery.getSourceList()[newQuery.getSourceList().Count - 1]).sourceObject, srcField, dstField);
                        }
                        //newQuery.addSource(new ATable(tablename, tableAlias), ABSTRACTSOURCEBINDTYPES.INNERJOIN, null, lTmp.Substring(0, lTmp.IndexOf('=')), lTmp.Substring(lTmp.IndexOf('=')+1));
                        break;
                    case "where":
                        // where b.id = sjilegj, b.Name = fjff
                        // where b.id = silegjlsg and
                        newQuery.conditionalString = paramString;
                        break;
                    case "group by":
                        fieldList = paramString.Split(',');
                        foreach(string ff in fieldList) {
                            newQuery.getField(ff).GroupBy = true;
                        }
                        break;
                    case "order by":
                        fieldList = paramString.Split(',');

                        foreach (string ff in fieldList)
                        {
                            /* patch...
                            bugfix: orderby where the field is not in the select field list
                            * ie: select * from [table] order by field
                            */
                            if (newQuery.getField(ff) == null)
                            {
                                newQuery.addField(newQuery.getDatabaseObject().GetTableCache().getCachedTable(((ATable)((QueryBuilder.SOURCEBINDING)newQuery.getSourceList()[0]).sourceObject).name).getFieldByName(ff));
                            }
                            if(ff.IndexOf(' ') > 0) {
                                ff.Trim();
                                string fname = ff.Substring(0, ff.IndexOf(' '));
                                string fOrderType = ff.Substring(ff.IndexOf(' ') + 1);
                                if (fOrderType.ToLower() == "asc")
                                    newQuery.getField(fname).OrderBy = ABSTRACTORDERTYPE.Ascending;
                                else
                                    newQuery.getField(fname).OrderBy = ABSTRACTORDERTYPE.Descending;
                            }
                            else { //default to order by asc
                                if (ff == newQuery.getField(ff).name)
                                {
                                    newQuery.getField(ff).OrderBy = ABSTRACTORDERTYPE.Ascending;
                                }
                            }
                        }
                        break;
                    case "limit":
                        newQuery.QueryLimit.lStart = 0;
                        if (paramString.IndexOf(',') > 0)
                        {
                            // format limit 0,5
                            // format limit offset, count
                            newQuery.QueryLimit.lStart = Convert.ToInt32(paramString.Substring(0, paramString.IndexOf(',')));
                            newQuery.QueryLimit.lLimit = Convert.ToInt32(paramString.Substring(paramString.IndexOf(',') + 1));
                        }
                        else
                            newQuery.QueryLimit.lLimit = Convert.ToInt32(paramString);
                        break;
                }
            }
        }
开发者ID:andrewjc,项目名称:sqlconsole,代码行数:101,代码来源:ProviderQueryConverters.cs


注:本文中的QueryBuilder.getDatabaseObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。