本文整理汇总了C#中IDataProvider.QualifyColumnName方法的典型用法代码示例。如果您正苦于以下问题:C# IDataProvider.QualifyColumnName方法的具体用法?C# IDataProvider.QualifyColumnName怎么用?C# IDataProvider.QualifyColumnName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataProvider
的用法示例。
在下文中一共展示了IDataProvider.QualifyColumnName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToQueryText
public string ToQueryText(IDataProvider dataProvider, ref int uniqueMarker)
{
if (dataProvider == null)
{
throw new ArgumentNullException("dataRepository", "Cannot create query part without a schema from the data repository.");
}
IColumn column = dataProvider.Schema.FindColumn(this.TableName, this.ColumnName);
if (column == null)
throw new QueryGenerationException("Could not find column schema information for the constraint: " + this.TableName + "." + this.ColumnName);
StringBuilder queryText = new StringBuilder(128);
this.Parameters.Clear();
// start with the opening paren
if (this.Negate)
{
queryText.Append("NOT (");
}
else
{
queryText.Append("(");
}
if (this.Comparison == ConstraintComparison.Between)
{
if (this.StartValue == null || this.EndValue == null)
throw new QueryGenerationException("Start or End value for a BETWEEN constraint is null");
// need to create the parameters
IDataParameter start = dataProvider.CreateParameter(uniqueMarker, column, this.StartValue);
uniqueMarker++; //always increment after using
this.Parameters.Add(start);
IDataParameter end = dataProvider.CreateParameter(uniqueMarker, column, this.EndValue);
uniqueMarker++; //always increment after using
this.Parameters.Add(end);
queryText.Append(dataProvider.QualifyColumnName(column));
queryText.Append(SqlFragment.BETWEEN);
queryText.Append(start.ParameterName);
queryText.Append(SqlFragment.AND);
queryText.Append(end.ParameterName);
}
else if (this.Comparison == ConstraintComparison.In || this.Comparison == ConstraintComparison.NotIn)
{
}
else
{
queryText.Append(dataProvider.QualifyColumnName(column));
queryText.Append(GetComparisonOperator(this.Comparison));
if (this.Comparison == ConstraintComparison.Is || this.Comparison == ConstraintComparison.IsNot)
{
if (this.ParameterValue == null || this.ParameterValue == DBNull.Value)
{
queryText.Append("NULL");
}
}
else
{
IDataParameter value = dataProvider.CreateParameter(uniqueMarker, column, this.ParameterValue);
uniqueMarker++; //always increment after using
this.Parameters.Add(value);
queryText.Append(value.ParameterName);
}
}
// add ending paren
queryText.Append(")");
return queryText.ToString();
}