Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public void Defense_Null_And_Empty()
 {
     Assert.True(PredicateHelper.Create <Person>(null)(Person.New()));
     Assert.True(PredicateHelper.Create <Person>("")(Person.New()));
 }
Ejemplo n.º 4
0
 public void String_Tests()
 {
     Assert.True(PredicateHelper.Create <Person>("Name = Ahmed Þeref")(Person.New(Name: "Ahmed Þeref")));
 }
Ejemplo n.º 5
0
 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)));
 }
Ejemplo n.º 6
0
        public void Complex_Queries(string command, Person person, bool expected)
        {
            Func <Person, bool> predicate = PredicateHelper.Create <Person>(command);

            Assert.Equal(expected, predicate(person));
        }
Ejemplo n.º 7
0
 public void Simple_Queries(string command, Person person, bool expected)
 {
     Assert.Equal(expected, PredicateHelper.Create <Person>(command)(person));
 }
Ejemplo n.º 8
0
 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"));
 }
Ejemplo n.º 9
0
 public void Integer_Queries(string q, int val, bool expected)
 {
     Assert.Equal(expected, PredicateHelper.Create <int>(q)(val));
 }