/// <inheritdoc /> public override IList <CriteriaExpression> GetExpressions() { var expressions = base.GetExpressions(); var expression = new CriteriaExpression(); if (this.CreatedBy != null) { expression.Equal("CreatedBy", this.CreatedBy); } if (this.EntityTypeName != null) { expression.Equal("EntityTypeName", this.EntityTypeName); } if (this.State != null) { expression.Equal("State", this.State); } if (this.RequestId != null) { expression.Equal("RequestId", this.RequestId); } expressions .Add(expression); return(expressions); }
public void BuildWhenEqualAndGuidNullableTest() { var criteriaExpression = new CriteriaExpression(); Guid?guid = Guid.NewGuid(); criteriaExpression.Equal("Id", guid); criteriaExpression.Equal("IdNullable", guid); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(criteriaExpression); Assert.IsNotNull(expression); Assert.AreEqual($"((x.Id == {guid}) AndAlso ((x.IdNullable != null) AndAlso (x.IdNullable == {guid})))", expression.Body.ToString()); }
public void BuildWhenMultipleCriteriaExpressionsTest() { var criteriaExpression1 = new CriteriaExpression(); criteriaExpression1.Equal("Name", "value"); var criteriaExpression2 = new CriteriaExpression(); criteriaExpression2.Equal("Name", "value2", LogicalType.Or); criteriaExpression2.Equal("Name", "value3"); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(new[] { criteriaExpression1, criteriaExpression2 }); Assert.IsNotNull(expression); Assert.IsNotNull(expression.Compile()); Assert.AreEqual("(((x.Name != null) AndAlso (x.Name == \"value\")) AndAlso (((x.Name != null) AndAlso (x.Name == \"value2\")) OrElse ((x.Name != null) AndAlso (x.Name == \"value3\"))))", expression.Body.ToString()); }
public void BuildWhenReferenceCollectionTest() { var criteriaExpression = new CriteriaExpression(); criteriaExpression.Equal("Orders[Payment.Id]", "value"); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(criteriaExpression); Assert.IsNotNull(expression); Assert.AreEqual("x.Orders.Any(i => ((i.Payment.Id != null) AndAlso (i.Payment.Id == \"value\")))", expression.Body.ToString()); }
public void BuildWhenReferenceTest() { var criteriaExpression = new CriteriaExpression(); criteriaExpression.Equal("Payment.Id", "value"); var builder = new CriteriaBuilder(); var expression = builder.Build <Order>(criteriaExpression); Assert.IsNotNull(expression); Assert.AreEqual("((x.Payment.Id != null) AndAlso (x.Payment.Id == \"value\"))", expression.Body.ToString()); }
public void BuildWhenEqualAndEnumTest() { var criteriaExpression = new CriteriaExpression(); criteriaExpression.Equal("Flags", FlagsEnum.One); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(criteriaExpression); Assert.IsNotNull(expression); Assert.AreEqual("((Convert(x.Flags, Int64) & Convert(One, Int64)) == Convert(One, Int64))", expression.Body.ToString()); }
public void BuildWhenEqualTest() { var criteriaExpression = new CriteriaExpression(); criteriaExpression.Equal("Name", "value"); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(criteriaExpression); Assert.IsNotNull(expression); Assert.AreEqual("((x.Name != null) AndAlso (x.Name == \"value\"))", expression.Body.ToString()); }
public void BuildWhenPropertyIsNotNullableAndValueIsNotNullableTest() { var guid = Guid.NewGuid(); var criteriaExpression = new CriteriaExpression(); criteriaExpression.Equal("Id", guid); var builder = new CriteriaBuilder(); var expression = builder.Build <Customer>(criteriaExpression); Assert.IsNotNull(expression); Assert.IsNotNull(expression.Compile()); Assert.AreEqual($"(x.Id == {guid})", expression.Body.ToString()); }
public void ConstructorWhenEqualWhenNullTest() { var expression = new CriteriaExpression(); expression.Equal("name", (string)null); var criteria = expression.Criterias.FirstOrDefault(); Assert.IsNotNull(criteria); Assert.AreEqual("name", criteria.Property); Assert.IsNull(criteria.Value); Assert.AreEqual(null, criteria.Value2); Assert.AreEqual(LogicalType.And, criteria.LogicalType); Assert.AreEqual(OperationType.IsNull, criteria.OperationType); }