Exemplo n.º 1
0
        /// <summary>
        /// Retorna lista de grupo filtrando pelo objeto por SQL query
        /// </summary>
        public static LIType FindBySql(IType objiType, string sql)
        {
            sql = string.Format(sql, GetTableName(objiType));
            if (objiType.Transaction != null)
            {
                return(new CData().FindBySql(ref objiType, sql));
            }

            string key      = CacheKeySql(sql);
            var    objCache = Cache.Get(key);

            if (objCache != null && !(objCache is LIType))
            {
                Cache.Invalidate(key);
            }
            LIType listWithCache = (LIType)Cache.Get(key);

            if (listWithCache != null)
            {
                return(listWithCache);
            }

            LIType list = new CData().FindBySql(ref objiType, sql);

            Cache.Add(key, list, DateTime.Now.AddMinutes(Cache.MinutesOfEspirationCache()));

            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retorna lista de grupo filtrando pelo objeto por condição
        /// </summary>
        public static LIType FindByConditions(IType objiType, string conditions)
        {
            if (objiType.Transaction != null)
            {
                return(new CData().FindByConditions(ref objiType, conditions));
            }

            string key      = CacheKey(objiType, conditions);
            var    objCache = Cache.Get(key);

            if (objCache != null && !(objCache is LIType))
            {
                Cache.Invalidate(key);
            }
            LIType listWithCache = (LIType)Cache.Get(key);

            if (listWithCache != null)
            {
                return(listWithCache);
            }

            LIType list = new CData().FindByConditions(ref objiType, conditions);

            Cache.Add(key, list, DateTime.Now.AddMinutes(Cache.MinutesOfEspirationCache()));

            return(list);
        }
Exemplo n.º 3
0
        protected LIType MakeListToGet(IType iType)
        {
            OpenConnectionTrans(iType);
            LIType       l  = new LIType();
            DbDataReader dr = Cmd.ExecuteReader();

            if (dr != null)
            {
                while (dr.Read())
                {
                    l.Add(SetObject(dr, (IType)Activator.CreateInstance(iType.GetType())));
                }
            }
            dr.Close();
            return(l);
        }