本文整理汇总了C#中Criteria.IsComposite方法的典型用法代码示例。如果您正苦于以下问题:C# Criteria.IsComposite方法的具体用法?C# Criteria.IsComposite怎么用?C# Criteria.IsComposite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Criteria
的用法示例。
在下文中一共展示了Criteria.IsComposite方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeCriteriaSource
private void MergeCriteriaSource(Criteria criteria)
{
if (criteria == null) return;
if (criteria.IsComposite())
{
MergeCriteriaSource(criteria.LeftCriteria);
MergeCriteriaSource(criteria.RightCriteria);
}
else
{
this.Source.MergeWith(criteria.Field.Source);
}
}
示例2: TestIsComposite_TrueForNotCriteria
public void TestIsComposite_TrueForNotCriteria()
{
//---------------Set up test pack-------------------
Criteria dateTimeCriteria = new Criteria("DateTime", Criteria.ComparisonOp.GreaterThan, DateTime.Now);
//---------------Execute Test ----------------------
Criteria notCriteria = new Criteria(Criteria.LogicalOp.Not, dateTimeCriteria);
//---------------Test Result -----------------------
Assert.IsTrue(notCriteria.IsComposite());
//---------------Tear Down -------------------------
}
示例3: TestIsComposite_True
public void TestIsComposite_True()
{
//---------------Set up test pack-------------------
Criteria dobCriteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, "sfd");
Criteria nameCriteria = new Criteria("Surname", Criteria.ComparisonOp.Equals, "dfsd");
Criteria twoPropCriteria = new Criteria(dobCriteria, Criteria.LogicalOp.And, nameCriteria);
//---------------Execute Test ----------------------
bool isComposite = twoPropCriteria.IsComposite();
//---------------Test Result -----------------------
Assert.IsTrue(isComposite, "A criteria made up of two others should be composite");
//---------------Tear Down -------------------------
}
示例4: TestIsComposite_False
public void TestIsComposite_False()
{
//---------------Set up test pack-------------------
Criteria criteria = new Criteria("bob", Criteria.ComparisonOp.LessThan, "hello");
//---------------Execute Test ----------------------
bool isComposite = criteria.IsComposite();
//---------------Test Result -----------------------
Assert.IsFalse(isComposite, "A single criteria should not be composite");
//---------------Tear Down -------------------------
}
示例5: TestConstruct_WithSpecifiedSource
public void TestConstruct_WithSpecifiedSource()
{
//---------------Set up test pack-------------------
const string propvalue = "PropValue";
//---------------Execute Test ----------------------
Criteria criteria = new Criteria("SourceName.PropName", Criteria.ComparisonOp.Equals, propvalue);
//---------------Test Result -----------------------
Assert.IsFalse(criteria.IsComposite());
Assert.AreEqual(Criteria.ComparisonOp.Equals, criteria.ComparisonOperator);
Assert.AreEqual(propvalue, criteria.FieldValue);
Assert.AreEqual("PropName", criteria.Field.PropertyName);
Assert.AreEqual("PropName", criteria.Field.FieldName);
Assert.AreEqual("SourceName", criteria.Field.Source.ToString());
}
示例6: PrepareDiscriminatorCriteria
///<summary>
///</summary>
///<param name="classDef"></param>
///<param name="criteria"></param>
public static void PrepareDiscriminatorCriteria(IClassDef classDef, Criteria criteria)
{
if (criteria == null) return;
if (criteria.IsComposite())
{
PrepareDiscriminatorCriteria(classDef, criteria.LeftCriteria);
PrepareDiscriminatorCriteria(classDef, criteria.RightCriteria);
}
else
{
criteria.Field.FieldName = criteria.Field.PropertyName;
criteria.Field.Source = new Source(((ClassDef)classDef).GetBaseClassOfSingleTableHierarchy().ClassNameExcludingTypeParameter,
classDef.GetTableName());
}
}
示例7: 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;
}
}
}
}