本文整理汇总了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;
}
示例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)
//.........这里部分代码省略.........