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


C# QueryBuilder.CreateParameterName方法代码示例

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


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

示例1: ConstructClassViewString

 internal override sealed string ConstructClassViewString(ClassViewAttribute cva, ConnectionPool pool, QueryBuilder builder, ref List<IDbDataParameter> queryParameters, ref int parCount)
 {
     string ret = FieldName+" ";
     if (FieldValue == null)
     {
         ret += ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
         queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), FieldValue));
         parCount++;
     }
     else if (FieldValue.GetType().IsArray || (FieldValue is ICollection))
     {
         if (SupportsList)
         {
             ret += " " + ComparatorString + " ( ";
             foreach (object obj in (IEnumerable)FieldValue)
             {
                 ret += builder.CreateParameterName("parameter_" + parCount.ToString()) + ",";
                 if (cva.Query.IsEnumField(FieldName))
                     queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), pool.GetEnumID(obj.GetType(), obj.ToString())));
                 else
                     queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), obj));
                 parCount++;
             }
             ret = ret.Substring(0, ret.Length - 1);
             ret += " )";
         }
         else
         {
             string tmp = ret + " " + ComparatorString+" ";
             ret = "(";
             foreach (object obj in (IEnumerable)FieldValue)
             {
                 ret += tmp+builder.CreateParameterName("parameter_" + parCount.ToString()) + " OR ";
                 if (cva.Query.IsEnumField(FieldName))
                     queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), pool.GetEnumID(obj.GetType(), obj.ToString())));
                 else
                     queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), obj));
                 parCount++;
             }
             ret = ret.Substring(0, ret.Length - 3);
             ret += ")";
         }
     }
     else
     {
         ret += ComparatorString + " ";
         ret += builder.CreateParameterName("parameter_" + parCount.ToString());
         if (cva.Query.IsEnumField(FieldName))
             queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), pool.GetEnumID(FieldValue.GetType(), FieldValue.ToString())));
         else
             queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), FieldValue));
         parCount++;
     }
     return ret;
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:55,代码来源:CompareParameter.cs

示例2: ConstructString

 internal sealed override string ConstructString(Type tableType, ConnectionPool pool, QueryBuilder builder, ref List<IDbDataParameter> queryParameters, ref int parCount)
 {
     bool found = false;
     string ret = "";
     FieldType? type=null;
     Type _objType = null;
     int fieldLength = 0;
     bool isExternal = false;
     bool isClassBased=false;
     Type newType;
     Type linkedType;
     string alias = "";
     string fldName = LocateTableField(FieldName,tableType, out isClassBased, out isExternal,out newType,out alias,out linkedType);
     found = fldName != null;
     if ((alias != null) && (alias.Length > 0))
         alias = "main_table_" + alias + ".";
     if (isExternal)
     {
         if (found)
         {
             if ((alias == "")||(alias==null))
                 alias = "main_table.";
             sTable relatedMap = pool.Mapping[newType];
             if (isClassBased)
             {
                 sTable map = pool.Mapping[linkedType];
                 if (FieldValue != null)
                 {
                     foreach (string prop in relatedMap.PrimaryKeyProperties)
                     {
                         foreach (sTableField fld in relatedMap[prop])
                         {
                             foreach (sTableField f in map[fldName])
                             {
                                 if (f.ExternalField == fld.Name)
                                 {
                                     ret += " AND " + (this.CaseInsensitive ? "UPPER(" : "") + alias + f.Name + (this.CaseInsensitive ? ")" : "") + " " + ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
                                     object val = QueryBuilder.LocateFieldValue((Org.Reddragonit.Dbpro.Structure.Table)FieldValue, fld, pool);
                                     queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), val, f.Type, f.Length));
                                     parCount++;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     foreach (sTableField f in map[fldName])
                     {
                         ret += " AND " + (this.CaseInsensitive ? "UPPER(" : "") + alias + f.Name + (this.CaseInsensitive ? ")" : "") + " " + ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
                         queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), null, f.Type, f.Length));
                         parCount++;
                     }
                 }
             }
             else
             {
                 foreach (string prop in relatedMap.PrimaryKeyProperties)
                 {
                     sTableField[] flds = relatedMap[prop];
                     if (flds[0].ExternalField != null)
                     {
                         Org.Reddragonit.Dbpro.Structure.Table tbl = null;
                         if (FieldValue != null)
                             tbl = (Org.Reddragonit.Dbpro.Structure.Table)QueryBuilder.LocateFieldValue((Org.Reddragonit.Dbpro.Structure.Table)FieldValue, flds[0], pool);
                         if (tbl != null)
                         {
                             sTable relMap = pool.Mapping[tbl.GetType()];
                             foreach (sTableField fld in relMap.Fields)
                             {
                                 foreach (sTableField f in flds)
                                 {
                                     if (fld.Name == f.ExternalField)
                                     {
                                         ret += " AND " + (this.CaseInsensitive ? "UPPER(" : "") + alias + flds[0].Name + (this.CaseInsensitive ? ")" : "") + " " + ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
                                         object val = QueryBuilder.LocateFieldValue(tbl, fld, pool);
                                         queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), val, fld.Type, fld.Length));
                                         parCount++;
                                         break;
                                     }
                                 }
                             }
                         }
                         else
                         {
                             foreach (sTableField fld in flds)
                             {
                                 ret += " AND " + (this.CaseInsensitive ? "UPPER(" : "") + alias + flds[0].Name + (this.CaseInsensitive ? ")" : "") + " " + ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
                                 queryParameters.Add(pool.CreateParameter(builder.CreateParameterName("parameter_" + parCount.ToString()), null, fld.Type, fld.Length));
                                 parCount++;
                             }
                         }
                     }
                     else
                     {
                         type = flds[0].Type;
                         fieldLength = flds[0].Length;
                         ret += " AND " + (this.CaseInsensitive ? "UPPER(" : "") + alias + flds[0].Name + (this.CaseInsensitive ? ")" : "") + " " + ComparatorString + " " + builder.CreateParameterName("parameter_" + parCount.ToString());
                         if (type == FieldType.ENUM)
//.........这里部分代码省略.........
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:101,代码来源:CompareParameter.cs


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