public virtual IEnumerable <T> Get(string q) { var query = PredicateHelper.Create <T>(q); var db = new NorthwindDbContext(); var result = db.Set <T>().Where(query).ToList(); return(result); }
public void Datetime_Tests() { var foo = new Foo() { DateTime = new DateTime(2000, 12, 31), }; Assert.True(PredicateHelper.Create <Foo>("DateTime.Year = 2000")(foo)); Assert.True(PredicateHelper.Create <Foo>("NullableDateTimeNull = null")(foo)); Assert.True(PredicateHelper.Create <Foo>("NullableDateTimeHasValue.Year = 2000")(foo)); }
public void Defense_Null_And_Empty() { Assert.True(PredicateHelper.Create <Person>(null)(Person.New())); Assert.True(PredicateHelper.Create <Person>("")(Person.New())); }
public void String_Tests() { Assert.True(PredicateHelper.Create <Person>("Name = Ahmed Þeref")(Person.New(Name: "Ahmed Þeref"))); }
public void Null_Queries() { Assert.True(PredicateHelper.Create <Person>("Name = null")(Person.New(Name: null))); Assert.True(PredicateHelper.Create <Person>("Name != null")(Person.New(Name: "Ahmed"))); Assert.False(PredicateHelper.Create <Person>("Name != null")(Person.New(Name: null))); }
public void Complex_Queries(string command, Person person, bool expected) { Func <Person, bool> predicate = PredicateHelper.Create <Person>(command); Assert.Equal(expected, predicate(person)); }
public void Simple_Queries(string command, Person person, bool expected) { Assert.Equal(expected, PredicateHelper.Create <Person>(command)(person)); }
public void String_Queries() { Assert.True(PredicateHelper.Create <string>("Length = 0")(string.Empty)); Assert.False(PredicateHelper.Create <string>("@ = Ahmed")("ahmed")); Assert.True(PredicateHelper.Create <string>("@ = Ahmed")("Ahmed")); }
public void Integer_Queries(string q, int val, bool expected) { Assert.Equal(expected, PredicateHelper.Create <int>(q)(val)); }