Esempio n. 1
0
        public YmtSystemDbContext CreateContext(Type storageContextType)
        {
            var contextType      = storageContextType;
            var contextAttribute = contextType.GetCustomAttributes(false).OfType <StoreContextAttribute>().SingleOrDefault();

            if (contextAttribute == null)
            {
                contextAttribute = new StoreContextAttribute();
            }

            var contextName = contextAttribute.StoreContextName;
            var scope       = DbConfigure.GetConfigure(contextName).Scope;

            return(YmtSystemDbContextScope <YmtSystemDbContext> .GetEntity(() => (YmtSystemDbContext)Activator.CreateInstance(contextType, contextName), scope));
        }
Esempio n. 2
0
        public TContext CreateContext <TContext>(Func <string, TContext> factory) where TContext : YmtSystemDbContext
        {
            var contextType = typeof(TContext);

            var contextAttribute = contextType.GetCustomAttributes(false).OfType <StoreContextAttribute>().SingleOrDefault();

            if (contextAttribute == null)
            {
                contextAttribute = new StoreContextAttribute();
            }

            var contextName = contextAttribute.StoreContextName;
            var scope       = DbConfigure.GetConfigure(contextName).Scope;

            return(YmtSystemDbContextScope <TContext> .GetEntity(() => factory(contextName), scope));
        }