Example #1
0
        //public TQuery CreateQueryToSharedSchema<TQuery>() where TQuery : BaseQuery
        //{
        //    return CreateQuery<TQuery>(SharedSchema);
        //}


        public BaseQuery CreateQuery(Type queryType, string schema)
        {
            // schema.Equals(SharedSchema) ? BaseConnectionString : SharedConnectionString is a hack this should be done in a better way
            // var perSchemaSqlDbContext = new PerSchemaSqlDbContext(schema.Equals(SharedSchema) ? SharedConnectionString : BaseConnectionString, schema);
            string conStr = Startup.Configuration["connStr"];
            var    perSchemaSqlDbContext = new PerSchemaSqlDbContext(conStr, schema);

            ConstructorArgument[] ctorArgs = new[] {
                new ConstructorArgument("dbContext", perSchemaSqlDbContext),
                new ConstructorArgument("provider", this)
            };

            return((BaseQuery)_injectKernel.Get(queryType, ctorArgs));
        }
Example #2
0
        protected BaseQuery(IQueryProvider provider, PerSchemaSqlDbContext dbContext)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider", "Query provider is not defined for query");
            }
            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext", "DB context is not defined for query");
            }

            DbContext = dbContext;
            Provider  = provider;
        }
Example #3
0
        /// <summary>
        /// Create a Query object with Schema specified
        /// </summary>
        /// <typeparam name="TQuery"></typeparam>
        /// <param name="schema"></param>
        /// <returns></returns>
        public TQuery CreateQuery <TQuery>(string schema) where TQuery : BaseQuery
        {
            // create the DB context per current schema
            // var perSchemaSqlDbContext = new PerSchemaSqlDbContext(schema.Equals(SharedSchema) ? SharedConnectionString : BaseConnectionString, schema);
            string conStr = Startup.Configuration["connStr"];
            var    perSchemaSqlDbContext = new PerSchemaSqlDbContext(conStr, schema);

            ConstructorArgument[] ctorArgs = new[] {
                new ConstructorArgument("dbContext", perSchemaSqlDbContext),
                new ConstructorArgument("provider", this)
            };

            // create a query with injected DB context
            return(_injectKernel.Get <TQuery>(ctorArgs));
        }
        protected StoredProcedureBase(IQueryProvider provider,
                                      PerSchemaSqlDbContext dbContext)
            : base(provider, dbContext)
        {
            // append the @ReturnVal OUTPUT parameter
            // so it's always known what code stored procedure
            // returns after execution
            SetParameter(paramName: "@ReturnVal",
                         paramValue: default(int),
                         sqlDbType: SqlDbType.Int,
                         isNullable: false,
                         direction: ParameterDirection.ReturnValue);

            // initialise out parameters which were tagged by OutTransactionAttribute to parameters map
            InitOutParameters();
        }
        protected StoredProcedureReturningCodeQuery(IQueryProvider provider,
                                                    PerSchemaSqlDbContext dbContext)
            : base(provider, dbContext)
        {
            // almost all CMS stored procedures have this
            // OUTPUT parameter to hold error message
            SetParameter(paramName: "@ErrorMessage",
                         paramValue: default(string),
                         sqlDbType: SqlDbType.VarChar,
                         isNullable: false,
                         direction: ParameterDirection.Output,
                         size: 500);

            // default behavior is to throw error
            // when the stored procedure returns a non-success code
            ThrowErrorOnNonSuccessCode = true;
        }
 protected StoredProcedureReturningSelectResultQuery(IQueryProvider provider, PerSchemaSqlDbContext dbContext) :
     base(provider, dbContext)
 {
 }
Example #7
0
 protected DataSelectCustomQuery(IQueryProvider provider,
                                 PerSchemaSqlDbContext dbContext)
     : base(provider, dbContext)
 {
 }