Exemplo n.º 1
0
        /// <summary>
        /// maq 执行分页
        /// </summary>
        public static PageResult QueryPage(PageModel pModel, string name, DbParameter[] param, DataContext db = null, string key = null, bool isOutSql = false)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);

                isOutSql = isOutSql ? isOutSql : IsMapLog(name);

                BaseAop.AopMapBefore(name, sql, param, config, AopType.Map_Page_Dic);

                var result = ExecuteSqlPage(pModel, sql, param, db, key, isOutSql);

                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result.list = MapXml.MapForEach(result.list, name, tempDb, key, config, i);
                            }
                        }
                    }
                    else
                    {
                        result.list = MapXml.MapForEach(result.list, name, db, key, config);
                    }
                }

                BaseAop.AopMapAfter(name, sql, param, config, AopType.Map_Page_Dic, result.list);
                return(result);
            }
            else
            {
                BaseAop.AopMapBefore(name, "", param, config, AopType.Map_Page_Dic);
                var data = new PageResult();
                BaseAop.AopMapAfter(name, "", param, config, AopType.Map_Page_Dic, data.list);
                return(data);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// maq 执行返回结果
        /// </summary>
        public List <T> Query <T>(string name, DbParameter[] param, DataContext db = null, string key = null, bool isOutSql = false) where T : class, new()
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }
            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);
                isOutSql = isOutSql ? isOutSql : IsMapLog(name);

                BaseAop.AopMapBefore(name, sql, param, config, AopType.Map_List_Model);

                var result = FastRead.ExecuteSql <T>(sql, param, db, key, isOutSql, false);
                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result = MapXml.MapForEach <T>(result, name, tempDb, config, i);
                            }
                        }
                    }
                    else
                    {
                        result = MapXml.MapForEach <T>(result, name, db, config);
                    }
                }

                BaseAop.AopMapAfter(name, sql, param, config, AopType.Map_List_Model, result);
                return(result);
            }
            else
            {
                BaseAop.AopMapBefore(name, "", param, config, AopType.Map_List_Model);
                var data = new List <T>();
                BaseAop.AopMapAfter(name, "", param, config, AopType.Map_List_Model, data);
                return(data);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// maq 执行分页
        /// </summary>
        public PageResult <T> QueryPage <T>(PageModel pModel, string name, DbParameter[] param, DataContext db = null, string key = null) where T : class, new()
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);

                var result = ExecuteSqlPage <T>(pModel, sql, param, db, key);

                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result.list = MapXml.MapForEach <T>(result.list, name, tempDb, config, i);
                            }
                        }
                    }
                    else
                    {
                        result.list = MapXml.MapForEach <T>(result.list, name, db, config);
                    }
                }

                return(result);
            }
            else
            {
                return(new PageResult <T>());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// maq 执行返回 List<Dictionary<string, object>>
        /// </summary>
        public List <Dictionary <string, object> > Query(string name, DbParameter[] param, DataContext db = null, string key = null)
        {
            key = key == null?MapDb(name) : key;

            var config = db == null?DataConfig.Get(key) : db.config;

            if (config.IsUpdateCache)
            {
                InstanceMap(key);
            }

            if (DbCache.Exists(config.CacheType, name.ToLower()))
            {
                var sql = MapXml.GetMapSql(name, ref param, db, key);

                var result = FastRead.ExecuteSql(sql, param, db, key);

                if (MapXml.MapIsForEach(name, config))
                {
                    if (db == null)
                    {
                        using (var tempDb = new DataContext(key))
                        {
                            for (var i = 1; i <= MapXml.MapForEachCount(name, config); i++)
                            {
                                result = MapXml.MapForEach(result, name, tempDb, key, config, i);
                            }
                        }
                    }
                    else
                    {
                        result = MapXml.MapForEach(result, name, db, key, config);
                    }
                }

                return(result);
            }
            else
            {
                return(new List <Dictionary <string, object> >());
            }
        }