protected void ClearCacheAfterChange(ISqlQuery query)
 {
     if (query.QueryType == QueryType.Delete ||
         query.QueryType == QueryType.Insert ||
         query.QueryType == QueryType.Update)
     {
         if (query is ISqlQueryMaker)
         {
             SqlQueryBuilderConfig.RemoveAllForTable(((ISqlQueryMaker)query).TableName);
         }
         else
         {
             SqlQueryBuilderConfig.Clear();
         }
     }
 }
Beispiel #2
0
        protected void RunQuery()
        {
            IDataReader DataReader;

            if (Buffered != DbBuffering.Buffered || !SqlQueryBuilderConfig.TryGetCachedData(Query, out DataReader))
            {
                DataReader = DataStorageController.RunQuery(Connection, Query, Transaction, CommandBehavior);
                DataReader = SqlQueryBuilderConfig.AddToCache(Query, DataReader);
            }

            // datareaderadapter will return a new Dictionary<string,object> when T is IDictionary<string,object>
            // we must map to an interim structure because of name-changes via SqlName

            var cInfo = IQ.ClassInfo <T>();

            var dra = new DataReaderAdapter <T>(DataReader,
                                                cInfo != null ?
                                                new Options {
                FieldNameMap = cInfo.SqlNameMap
            }:
                                                null);

            dra.OnLoad = OnLoad;
            dra.Target = Target;



            //IEnumerable<T> wrapper = GetFinalSequence(dra);

            if (Buffered == DbBuffering.Buffered)
            {
                var list = new List <T>();
                list.AddRange(dra);
                Data = list;
            }
            else
            {
                Data = dra;
            }
        }