public IEnumerable <TDestModel> Handle(AutoMapperQuery <TSrcEntity, TDestModel> query)
        {
            using (var dbContextScope = _dbContextScopeFactory.CreateReadOnly())
            {
                // Gets our context from our context scope
                var dbCtx = dbContextScope.DbContexts.GetByInterface <IDbContext>();
                dbCtx.DbCtx.Configuration.ProxyCreationEnabled = false;
                var testSet = dbCtx.DbCtx.Set <TSrcEntity>().Project().To <TDestModel>().ToList();

                return(testSet);
            }
        }
Пример #2
0
        public IEnumerable <TDestModel> Handle(AutoMapperQuery <TSrcEntity, TDestModel> args)
        {
            using (var dbContextScope = _dbContextScopeFactory.CreateReadOnly())
            {
                // Gets our context from our context scope
                var dbCtx = dbContextScope.DbContexts.GetByInterface <ISchoolDbContext>();

                IQueryable <TSrcEntity> srcEntities = dbCtx.Set <TSrcEntity>();

                srcEntities = srcEntities.Where(args);
                IQueryable <TDestModel> destEntities = srcEntities.Project().To <TDestModel>();
                destEntities = destEntities.OrderBy(args);
                return(destEntities.Take(args.PageSize).ToList());
            }
        }