예제 #1
0
        private void InitContext(ConnectionConfig config)
        {
            var aopIsNull = config.AopEvents == null;

            if (aopIsNull)
            {
                config.AopEvents = new AopEvents();
            }
            _Context = new AgileProvider(config);
            if (!aopIsNull)
            {
                _Context.Ado.IsEnableLogEvent = true;
            }
            this.CurrentConnectionConfig = config;
            _ThreadId = Thread.CurrentThread.ManagedThreadId.ToString();
            if (_MappingColumns == null)
            {
                this.MappingTables = new MappingTableList();
            }
            if (this.MappingColumns == null)
            {
                this.MappingColumns = new MappingColumnList();
            }
            if (this.IgnoreColumns == null)
            {
                this.IgnoreColumns = new IgnoreColumnList();
            }
            if (this.IgnoreInsertColumns == null)
            {
                this.IgnoreInsertColumns = new IgnoreColumnList();
            }
        }
예제 #2
0
        protected async Task <List <T> > GetEntityListAsync <T>(AgileProvider context, IDataReader dataReader)
        {
            Type   type       = typeof(T);
            var    fieldNames = GetDataReaderNames(dataReader);
            string cacheKey   = GetCacheKey(type, fieldNames);
            IDataReaderEntityBuilder <T> entytyList = context.Utilities.GetReflectionInoCacheInstance().GetOrCreate(cacheKey, () =>
            {
                var cacheResult = new IDataReaderEntityBuilder <T>(context, dataReader, fieldNames).CreateBuilder(type);
                return(cacheResult);
            });
            List <T> result = new List <T>();

            try
            {
                if (dataReader == null)
                {
                    return(result);
                }
                while (await((DbDataReader)dataReader).ReadAsync())
                {
                    result.Add(entytyList.Build(dataReader));
                }
            }
            catch (Exception ex)
            {
                Check.Exception(true, ErrorMessage.EntityMappingError, ex.Message);
            }
            return(result);
        }
예제 #3
0
 public IDataReaderEntityBuilder(AgileProvider context, IDataRecord dataRecord, List <string> fieldNames)
 {
     this.Context        = context;
     this.DataRecord     = dataRecord;
     this.DynamicBuilder = new IDataReaderEntityBuilder <T>();
     this.ReaderKeys     = fieldNames;
 }
예제 #4
0
        private AgileProvider GetContext()
        {
            AgileProvider result = null;

            if (IsSameThreadAndShard())
            {
                result = SameThreadAndShard();
            }
            else if (IsNoSameThreadAndShard())
            {
                result = NoSameThreadAndShard();
            }
            else if (IsSynchronization())
            {
                result = Synchronization();
            }
            else if (IsSingleInstanceAsync())
            {
                result = Synchronization();//Async no support  Single Instance
            }
            else if (IsAsync())
            {
                result = Synchronization();
            }
            else
            {
                IsSingleInstance = true;
                result           = NoSameThread();
            }
            if (result.Root == null)
            {
                result.Root = this;
            }
            return(result);
        }
예제 #5
0
 internal SaveableProvider(AgileProvider context, T saveObject)
 {
     this.saveObjects = new List <T>()
     {
         saveObject
     };
     this.Context = context;
     this.Context.InitMappingInfo <T>();
 }
예제 #6
0
 private void InitTenant(AgileTerant Tenant)
 {
     if (Tenant.Context == null)
     {
         Tenant.Context = new AgileProvider(Tenant.ConnectionConfig);
     }
     _Context = Tenant.Context;
     this.CurrentConnectionConfig = Tenant.ConnectionConfig;
 }
예제 #7
0
        public static CacheKey GetKey(AgileProvider context, QueryBuilder queryBuilder)
        {
            CacheKey result = new CacheKey();

            result.Database = context.Context.Ado.Connection.Database;
            AddTables(context, queryBuilder, result);
            AddIdentificationList(queryBuilder, result);
            return(result);
        }
예제 #8
0
 public UtilExceptions(AgileProvider context, Exception ex, string sql, object pars)
     : base(ex.Message)
 {
     this.Sql            = sql;
     this.Parametres     = pars;
     this.InnerException = ex.InnerException;
     this.StackTrace     = ex.StackTrace;
     this.TargetSite     = ex.TargetSite;
     this.Source         = ex.Source;
 }
예제 #9
0
        private AgileProvider CopyClient()
        {
            var result = new AgileProvider(this.CurrentConnectionConfig);

            result.MappingColumns      = _MappingColumns;
            result.MappingTables       = _MappingTables;
            result.IgnoreColumns       = _IgnoreColumns;
            result.IgnoreInsertColumns = _IgnoreInsertColumns;

            return(result);
        }
예제 #10
0
        public AgileProvider CopyContext(bool isCopyEvents = false)
        {
            var newClient = new AgileProvider(this.TranslateCopy(Context.CurrentConnectionConfig));

            newClient.CurrentConnectionConfig.ConfigureExternalServices = Context.CurrentConnectionConfig.ConfigureExternalServices;
            newClient.MappingColumns      = this.TranslateCopy(Context.MappingColumns);
            newClient.MappingTables       = this.TranslateCopy(Context.MappingTables);
            newClient.IgnoreColumns       = this.TranslateCopy(Context.IgnoreColumns);
            newClient.IgnoreInsertColumns = this.TranslateCopy(Context.IgnoreInsertColumns);
            if (isCopyEvents)
            {
                newClient.QueryFilter = Context.QueryFilter;
                newClient.CurrentConnectionConfig.AopEvents = Context.CurrentConnectionConfig.AopEvents;
            }
            return(newClient);
        }
예제 #11
0
 public UtilExceptions(AgileProvider context, string message, string sql)
     : base(message)
 {
     this.Sql = sql;
 }
예제 #12
0
 internal SaveableProvider(AgileProvider context, List <T> saveObjects)
 {
     this.saveObjects = saveObjects;
     this.Context     = context;
     this.Context.InitMappingInfo <T>();
 }
예제 #13
0
        public static T GetOrCreate <T>(ICacheService cacheService, QueryBuilder queryBuilder, Func <T> getData, int cacheDurationInSeconds, AgileProvider context)
        {
            CacheKey key       = CacheKeyBuider.GetKey(context, queryBuilder);
            string   keyString = key.ToString();
            var      result    = cacheService.GetOrCreate(keyString, getData, cacheDurationInSeconds);

            return(result);
        }
예제 #14
0
 public UtilExceptions(AgileProvider context, string message, object pars)
     : base(message)
 {
     this.Parametres = pars;
 }
예제 #15
0
 private void AddCallContext(AgileProvider context)
 {
     CallContext.ContextList.Value = new List <AgileProvider>();
     CallContext.ContextList.Value.Add(context);
 }
예제 #16
0
 public static object GetEntity(this IDataReader dr, AgileProvider context)
 {
     return(null);
 }
예제 #17
0
 public AopProvider(AgileProvider context)
 {
     this.Context = context;
     this.Context.Ado.IsEnableLogEvent = true;
 }