Exemplo n.º 1
0
        public IList <T> GetAllLazyLoading(Func <T, object> aOrderFunc, OrderFunctionType aOrderFunctionType, params Expression <Func <T, object> >[] aNavigationProperties)
        {
            try
            {
                List <T>       _List;
                IQueryable <T> _DbQuery = fContext.Set <T>();

                foreach (Expression <Func <T, object> > _NavigationProperty in aNavigationProperties)
                {
                    _DbQuery = _DbQuery.Include(_NavigationProperty);
                }

                _List = aOrderFunctionType == OrderFunctionType.Descending ? _DbQuery.AsNoTracking().OrderByDescending(aOrderFunc).ToList() : _DbQuery.AsNoTracking().OrderBy(aOrderFunc).ToList();

                if (fDisposeContextOnEveryAction)
                {
                    fContext.Dispose();
                }
                return(_List);
            }
            catch (Exception _Exception)
            {
                MethodBase _MetodInfo = MethodInfo.GetCurrentMethod();
                throw HandleException(_Exception, _MetodInfo);
            }
        }
Exemplo n.º 2
0
        public IList <TU> GetListWithSelectLazyLoading <TU>(Func <T, bool> aWhere, int aPage, int aCount, out int aPageCount, Func <T, object> aOrderFunc, Func <T, TU> aSelectFunc,
                                                            OrderFunctionType aOrderFunctionType, params Expression <Func <T, object> >[] aNavigationProperties)
        {
            try
            {
                List <TU> _List;

                IQueryable <T> _DbQuery = fContext.Set <T>();
                foreach (Expression <Func <T, object> > _NavigationProperty in aNavigationProperties)
                {
                    _DbQuery = _DbQuery.Include(_NavigationProperty);
                }


                aPage -= 1;
                var _AllItemsCount = _DbQuery.Count(aWhere);
                if (_AllItemsCount % aCount == 0)
                {
                    aPageCount = _AllItemsCount / aCount;
                }
                else
                {
                    aPageCount = _AllItemsCount / aCount + 1;
                }

                _List = aOrderFunctionType == OrderFunctionType.Descending ? _DbQuery.AsNoTracking().Where(aWhere).OrderByDescending(aOrderFunc).Skip(aPage * aCount).Take(aCount).Select(aSelectFunc).ToList() : _DbQuery.AsNoTracking().Where(aWhere).OrderBy(aOrderFunc).Skip(aPage * aCount).Take(aCount).Select(aSelectFunc).ToList();

                if (fDisposeContextOnEveryAction)
                {
                    fContext.Dispose();
                }

                return(_List);
            }
            catch (Exception _Exception)
            {
                MethodBase _MetodInfo = MethodInfo.GetCurrentMethod();
                throw HandleException(_Exception, _MetodInfo);
            }
        }
Exemplo n.º 3
0
 public IList <TU> GetAllWithSelect <TU>(int aPage, int aCount, out int aPageCount, Func <T, object> aOrderFunc, Func <T, TU> aSelectFunc,
                                         OrderFunctionType aOrderFunctionType)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public IList <TU> GetAllWithSelect <TU>(Func <T, object> aOrderFunc, Func <T, TU> aSelectFunc, OrderFunctionType aOrderFunctionType) where TU : class
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public IList <T> GetAll(Func <T, object> aOrderFunc, OrderFunctionType aOrderFunctionType)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public IList <T> GetList(Func <T, bool> aWhere, int aPage, int aCount, out int aPageCount, Func <T, object> aOrderFunc,
                          OrderFunctionType aOrderFunctionType)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        public IList <TU> GetListWithSelect <TU>(Func <T, bool> aWhere, Func <T, object> aOrderFunc, Func <T, TU> aSelectFunc, OrderFunctionType aOrderFunctionType) where TU : class
        {
            try
            {
                List <TU> _List;

                fContext.Configuration.LazyLoadingEnabled = false;
                IQueryable <T> _DbQuery = fContext.Set <T>();
                _List = aOrderFunctionType == OrderFunctionType.Descending ? _DbQuery.AsNoTracking().OrderByDescending(aOrderFunc).Select(aSelectFunc).ToList() : _DbQuery.AsNoTracking().OrderBy(aOrderFunc).Select(aSelectFunc).ToList();

                if (fDisposeContextOnEveryAction)
                {
                    fContext.Dispose();
                }

                return(_List);
            }
            catch (Exception _Exception)
            {
                MethodBase _MetodInfo = MethodInfo.GetCurrentMethod();
                throw HandleException(_Exception, _MetodInfo);
            }
        }