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


C# IDataProvider.QualifyColumnName方法代码示例

本文整理汇总了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();
        }
开发者ID:jdaigle,项目名称:Centro,代码行数:71,代码来源:ColumnConstraint.cs


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