Esempio n. 1
0
        public void GetListBatchLoading()
        {
            using (var ds = new DataService())
            {
                ds.ResetDatabase();

                for (int a = 1; a <= 100; a++)
                {
                    var newProduct1 = new T_E_Product();
                    newProduct1.Ranking     = a;
                    newProduct1.Description = a + " Product";

                    newProduct1 = ds.Add(newProduct1);

                    var newPicture = new T_E_Picture();
                    newPicture.Name      = "picture " + newProduct1.Description;
                    newPicture.ProductId = newProduct1.ProductId;

                    newPicture = ds.Add(newPicture);
                }

                var navPictureList = new List <System.Linq.Expressions.Expression <Func <T_E_Picture, object> > >();
                navPictureList.Add(x => x.T_E_Product);
                if (ds.GetList <T_E_Picture>(null, navPictureList).ToList().Where(x => x.T_E_Product != null).Count() != 100)
                {
                    throw new Exception();
                }
                if (ds.GetList <T_E_Picture>().ToList().Enum().Where(x => x.T_E_Product != null).Count() != 0)
                {
                    throw new Exception();
                }

                var iquery = ds.GetListBatchLoading <T_E_Picture, long>(x => x.PictureId, System.ComponentModel.ListSortDirection.Descending, navPictureList, null, 10, 10);

                if (iquery.Where(x => x.T_E_Product == null).IsNotNullAndNotEmpty())
                {
                    throw new Exception();
                }

                ds.ResetDatabase();
            }
        }
Esempio n. 2
0
        public void GetSingle()
        {
            using (var ds = new DataService())
            {
                ds.ResetDatabase();

                var newProduct1 = new T_E_Product();
                newProduct1.Ranking     = 1;
                newProduct1.Description = "Product";
                newProduct1             = ds.Add(newProduct1);

                var newPicture = new T_E_Picture();
                newPicture.ProductId = newProduct1.ProductId;
                newPicture.Name      = "picture";
                newPicture           = ds.Add(newPicture);

                var get1 = ds.GetSingle <T_E_Product>(x => x.Ranking == 1);
                if (get1.Ranking != 1)
                {
                    throw new Exception();
                }
                if (get1.Description != "Product")
                {
                    throw new Exception();
                }

                var navPictureList = new List <System.Linq.Expressions.Expression <Func <T_E_Picture, object> > >();
                navPictureList.Add(x => x.T_E_Product);

                var get2 = ds.GetSingle <T_E_Picture>(x => x.Name == "picture", navPictureList);
                if (get2.T_E_Product == null)
                {
                    throw new Exception();
                }
                ds.ResetDatabase();
            }
        }
Esempio n. 3
0
        public void GetList()
        {
            using (var ds = new DataService())
            {
                ds.ResetDatabase();

                for (int a = 1; a <= 100; a++)
                {
                    var newProduct1 = new T_E_Product();
                    newProduct1.Ranking     = a;
                    newProduct1.Description = a + " Product";

                    newProduct1 = ds.Add(newProduct1);

                    var newPicture = new T_E_Picture();
                    newPicture.Name      = "picture " + newProduct1.Description;
                    newPicture.ProductId = newProduct1.ProductId;

                    newPicture = ds.Add(newPicture);
                }

                //GetList<T>
                if (ds.GetList <T_E_Product>().Count() != 100)
                {
                    throw new Exception();
                }
                if (ds.GetList <T_E_Product>(x => x.Description.Contains("Product")).Count() != 100)
                {
                    throw new Exception();
                }

                var navPictureList = new List <System.Linq.Expressions.Expression <Func <T_E_Picture, object> > >();
                navPictureList.Add(x => x.T_E_Product);
                if (ds.GetList <T_E_Picture>(null, navPictureList).ToList().Where(x => x.T_E_Product != null).Count() != 100)
                {
                    throw new Exception();
                }
                if (ds.GetList <T_E_Picture>().ToList().Enum().Where(x => x.T_E_Product != null).Count() != 0)
                {
                    throw new Exception();
                }

                //GetList<T,Tkey>
                var iquery = ds.GetList <T_E_Product, int>(null, null, x => x.Ranking, System.ComponentModel.ListSortDirection.Descending);

                if (iquery.First().Ranking != 100)
                {
                    throw new Exception();
                }
                if (iquery.Last().Ranking != 1)
                {
                    throw new Exception();
                }

                iquery = ds.GetList <T_E_Product, int>(null, null, x => x.Ranking, System.ComponentModel.ListSortDirection.Descending, 10, 10);
                if (iquery.Count() != 10)
                {
                    throw new Exception();
                }
                if (iquery.First().Ranking != 90)
                {
                    throw new Exception();
                }
                if (iquery.Last().Ranking != 81)
                {
                    throw new Exception();
                }

                ds.ResetDatabase();
            }
        }