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


C# Criteria.CanBeParametrised方法代码示例

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


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

示例1: TestNotIn

        public void TestNotIn()
        {
            //-------------Setup Test Pack ------------------
            //-------------Test Pre-conditions --------------

            //-------------Execute test ---------------------
            object[] values = new object[] { "100", "200", "300" };
            Criteria.CriteriaValues criteriaValues = new Criteria.CriteriaValues(values);
            Criteria criteria = new Criteria("MyField", Criteria.ComparisonOp.NotIn, criteriaValues);

            //-------------Test Result ----------------------
            Assert.IsNotNull(criteria.Field);
            Assert.AreEqual("MyField", criteria.Field.PropertyName);
            Assert.IsNull(criteria.Field.Source);
            Assert.AreEqual("MyField", criteria.Field.FieldName);
            Assert.AreEqual(Criteria.ComparisonOp.NotIn, criteria.ComparisonOperator);
            Assert.IsTrue(criteria.CanBeParametrised());
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:18,代码来源:TestCriteria.cs

示例2: PrepareCriteria

 ///<summary>
 /// Based on the class definition the given <see cref="Criteria"/> object is set up with the correct entity 
 /// names and field names, in preparation for using it as part of a <see cref="SelectQuery"/> that has been built using
 /// the <see cref="QueryBuilder"/> and the same <see cref="ClassDef"/>
 ///</summary>
 ///<param name="classDef">The class definition to use for preparing the <see cref="Criteria"/>.</param>
 ///<param name="criteria">The <see cref="Criteria"/> to prepare for use with a <see cref="SelectQuery"/>.</param>
 public static void PrepareCriteria(IClassDef classDef, Criteria criteria)
 {
     if (classDef == null) throw new ArgumentNullException("classDef");
     if (criteria == null) return;
     if (criteria.IsComposite())
     {
         PrepareCriteria(classDef, criteria.LeftCriteria);
         PrepareCriteria(classDef, criteria.RightCriteria);
     }
     else
     {
         var field = criteria.Field;
         var fieldPropDef = PrepareField(field.Source, classDef, field);
         if (fieldPropDef != null)
         {
             field.FieldName = fieldPropDef.DatabaseFieldName;
             if (null == field.Source) throw new NullReferenceException("the field.Source is null");
             if (null == field.Source.RelatedClassDef) throw new NullReferenceException("the field.Source.RelatedClassDef is null");
             if (null == field.Source.ChildSourceLeaf) throw new NullReferenceException("the field.Source.ChildSourceLeaf is null");
             field.Source.ChildSourceLeaf.EntityName = field.Source.RelatedClassDef.GetTableName(fieldPropDef);
             if (criteria.CanBeParametrised()
                     && (criteria.ComparisonOperator != Criteria.ComparisonOp.In 
                     && criteria.ComparisonOperator != Criteria.ComparisonOp.NotIn))
             {
                 object returnedValue;
                 fieldPropDef.TryParsePropValue(criteria.FieldValue, out returnedValue);
                 criteria.FieldValue = returnedValue;
             }
         }
     }
 }
开发者ID:Celtic691,项目名称:habanero,代码行数:38,代码来源:QueryBuilder.cs


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