Example #1
0
        //With SqlDependency
        public GenericType EncapsulatedRead <GenericType>(object ParametersObject, string ProcedureName, int RowIndex, bool AllowCache)
        {
            if (AllowCache)
            {
                CacheBase cb        = new CacheBase();
                object    cachedObj = cb[ParametersObject];

                if (cachedObj != null)
                {
                    return((GenericType)cachedObj);
                }
                else
                {
                    GenericType ret = (GenericType)System.Activator.CreateInstance(typeof(GenericType));
                    ExtractObject <GenericType>(ReturnDataTable(ParametersObject, ProcedureName), ret, RowIndex);
                    SqlDependencyExpiration dependency = GetSQLDependency(ParametersObject, ProcedureName);
                    return(cb.Add <GenericType>(ParametersObject, ret, dependency));
                }
            }
            else
            {
                GenericType ret = (GenericType)System.Activator.CreateInstance(typeof(GenericType));
                ExtractObject <GenericType>(ReturnDataTable(ParametersObject, ProcedureName), ret, RowIndex);
                return(ret);
            }
        }
Example #2
0
        //You inform Expiration Police
        public List <GenericType> EncapsulatedRead <GenericType>(object ParametersObject, string ProcedureName, params ICacheItemExpiration[] expirations)
        {
            CacheBase cb        = new CacheBase();
            object    cachedObj = cb[ParametersObject];

            if (cachedObj != null)
            {
                return((List <GenericType>)cachedObj);
            }
            else
            {
                return(cb.Add <List <GenericType> >(ParametersObject
                                                    , EncapsulatedRead <GenericType>(ParametersObject, ProcedureName)
                                                    , expirations));
            }
        }
Example #3
0
        /// <summary>
        /// Used to extract a single object from a specific row of the DataTable.
        /// </summary>
        /// <typeparam name="GenericType">Type of object to extract</typeparam>
        /// <param name="ParametersObject">Object with suplied execution params for the procedure</param>
        /// <param name="ProcedureName">Name of the procedure to be executed</param>
        /// <param name="index">Index of the row in the DataTable to extract the object from</param>
        /// <returns>Populated typed business object.</returns>
        ///



        //You inform Expiration Police
        public GenericType EncapsulatedRead <GenericType>(object ParametersObject, string ProcedureName, int RowIndex, params ICacheItemExpiration[] expirations)
        {
            CacheBase cb        = new CacheBase();
            object    cachedObj = cb[ParametersObject];

            if (cachedObj != null)
            {
                return((GenericType)cachedObj);
            }
            else
            {
                GenericType ret = (GenericType)System.Activator.CreateInstance(typeof(GenericType));
                ExtractObject <GenericType>(ReturnDataTable(ParametersObject, ProcedureName), ret, RowIndex);

                return(cb.Add <GenericType>(ParametersObject
                                            , ret
                                            , expirations));
            }
        }
Example #4
0
        //With SqlDependency
        public List <GenericType> EncapsulatedRead <GenericType>(object ParametersObject, string ProcedureName, bool AllowCache)
        {
            if (AllowCache)
            {
                CacheBase cb        = new CacheBase();
                object    cachedObj = cb[ParametersObject];

                if (cachedObj != null)
                {
                    return((List <GenericType>)cachedObj);
                }
                else
                {
                    return(cb.Add <List <GenericType> >(ParametersObject
                                                        , EncapsulatedRead <GenericType>(ParametersObject, ProcedureName)
                                                        , GetSQLDependency(ParametersObject, ProcedureName)));
                }
            }

            return(EncapsulatedRead <GenericType>(ParametersObject, ProcedureName));
        }