示例#1
0
 private static InMemoryLinqProvider LinqProvider()
 {
     var category = new Category(100, "Smarphones");
     var linqProvider = new InMemoryLinqProvider(
         new[] {new Product(category, "iPhone", 100500), new Product(category, "Galaxy s7", 3500)});
     return linqProvider;
 }
示例#2
0
        public void DynamicLinq_Tests()
        {
            var lp = new InMemoryLinqProvider(new[]
            {
                new Product()
                {
                    Name = "123", Id = 1
                }
                , new Product()
                {
                    Name = "234"
                }
            });

            var val = lp.GetQueryable <Product>().Where("Name = \"123\"").ToArray();

            var autoFilter = new AutoFilter <Product>();

            autoFilter.Filter.Add("Name", "123");
            autoFilter.Filter.Add("Id", 1);

            var q = autoFilter.Apply(lp.GetQueryable <Product>());

            var res = q.ToArray();
        }
示例#3
0
        private static InMemoryLinqProvider LinqProvider()
        {
            var category     = new Category(100, "Smarphones");
            var linqProvider = new InMemoryLinqProvider(
                new[] { new Product(category, "iPhone", 100500), new Product(category, "Galaxy s7", 3500) });

            return(linqProvider);
        }
        public void LinqProvider_ById()
        {
            var provider = new InMemoryLinqProvider(new[]
            {
                new Product()
                {
                    Id = 1
                }, new Product()
                {
                    Id = 2
                },
            });


            var id1 = provider.ById <Product>(1).Id;
            var id2 = provider.ById <Product>(2).Id;

            Assert.Equal(1, id1);
            Assert.Equal(2, id2);
        }
示例#5
0
        public void DynamicLinq_Tests()
        {
            var lp = new InMemoryLinqProvider(new[]
            {
                new Product() {Name = "123", Id = 1}
                , new Product() {Name = "234"}
            });

            var val = lp.GetQueryable<Product>().Where("Name = \"123\"").ToArray();

            var autoFilter = new AutoFilter<Product>();
            autoFilter.Filter.Add("Name", "123");
            autoFilter.Filter.Add("Id", 1);

            var q = autoFilter.Apply(lp.GetQueryable<Product>());

            var res = q.ToArray();
        }