Exemple #1
0
        public int Create(TEntity entity)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, "CREATE");
            var sql      = GetSqlCache(cacheKey, this.ConnString, "CREATE", this.Provider);

            return(this.ExecSqlImpl(cacheKey, sql, CommandType.Text, entity));
        }
Exemple #2
0
        public async Task <PagedList <TTarget> > QueryPageAsync <TTarget>(string sql, int pageIndex, int pageSize, string orderBy = null, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql + orderBy ?? "");

            sql = RepositoryHelper.GetPagingCache(cacheKey, this.ConnString, sql, pageIndex, pageSize, orderBy, this.Provider);
            return(await this.QueryPageImplAsync <TTarget>(cacheKey, typeof(TTarget), sql, cmdType, objParameter));
        }
Exemple #3
0
        public int Update <TFields>(Expression <Func <TEntity, TFields> > fieldsExpression, TEntity objParameter = null)
        {
            var sql      = GetUpdateFieldsSql(fieldsExpression, this.Provider);
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(this.ExecSqlImpl(cacheKey, sql, CommandType.Text, objParameter));
        }
Exemple #4
0
        public int Delete(TEntity key)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, "DELETE");
            var sql      = GetSqlCache(cacheKey, this.ConnString, "DELETE", this.Provider);

            return(this.ExecSqlImpl(cacheKey, sql, CommandType.Text, key, true));
        }
Exemple #5
0
        public async Task <TEntity> GetAsync(TEntity key)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, "GET");
            var sql      = GetSqlCache(cacheKey, this.ConnString, "GET", this.Provider);

            return(await this.QueryFirstImplAsync <TEntity>(cacheKey, Mapper.EntityType, sql, CommandType.Text, key));
        }
Exemple #6
0
        public async Task <int> DeleteAsync(TEntity key)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, "DELETE");
            var sql      = GetSqlCache(cacheKey, this.ConnString, "DELETE", this.Provider);

            return(await this.ExecSqlImplAsync(cacheKey, sql, CommandType.Text, key));
        }
Exemple #7
0
        public PagedList <TEntity> QueryPage(string sql, int pageIndex, int pageSize, string orderBy = null, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql + orderBy ?? "");

            sql = RepositoryHelper.GetPagingCache(cacheKey, this.ConnString, sql, pageIndex, pageSize, orderBy, this.Provider);
            return(this.QueryPageImpl <TEntity>(cacheKey, Mapper.EntityType, sql, cmdType, objParameter));
        }
Exemple #8
0
        public TEntity Get(TEntity key)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, "GET");
            var sql      = GetSqlCache(cacheKey, this.ConnString, "GET", this.Provider);

            return(this.QueryFirstImpl <TEntity>(cacheKey, Mapper.EntityType, sql, CommandType.Text, key, true));
        }
Exemple #9
0
        public async Task <PagedList <TEntity> > QueryPageAsync <TEntity>(string sql, int pageIndex, int pageSize, string orderBy = null, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql, paramType);

            return(await this.QueryPageImplAsync <TEntity>(cacheKey, typeof(TEntity), sql, cmdType, objParameter, paramType));
        }
Exemple #10
0
        public async Task <int> ExecSqlAsync(string sql, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql, paramType);

            return(await this.ExecSqlImplAsync(cacheKey, sql, cmdType, objParameter, paramType));
        }
Exemple #11
0
        public List <TEntity> Query <TEntity>(string sql, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql, paramType);

            return(this.QueryImpl <TEntity>(cacheKey, typeof(TEntity), sql, cmdType, objParameter, paramType));
        }
Exemple #12
0
        public PagedList <TEntity> QueryPage <TEntity>(string sql, int pageIndex, int pageSize, string orderBy = null, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql + orderBy ?? "", paramType);

            sql = RepositoryHelper.GetPagingCache(cacheKey, this.ConnString, sql, pageIndex, pageSize, orderBy, this.Provider);
            return(this.QueryPageImpl <TEntity>(cacheKey, typeof(TEntity), sql, cmdType, objParameter, paramType));
        }
Exemple #13
0
        public async Task <QueryReader> QueryMultipleAsync(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            if (this.Connection == null)
            {
                return(await this.QueryMultipleImplAsync(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, true));
            }
            else
            {
                return(await this.QueryMultipleImplAsync(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, false));
            }
        }
Exemple #14
0
        public TTarget QueryMap <TTarget>(Func <QueryReader <TTarget>, TTarget> mapping, string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);
            QueryReader <TTarget> reader = null;

            if (this.Connection == null)
            {
                reader = this.QueryMultipleImpl <TTarget>(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, true);
            }
            else
            {
                reader = this.QueryMultipleImpl <TTarget>(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, false);
            }
            return(mapping(reader));
        }
Exemple #15
0
        public QueryReader QueryMultiple(string sql, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            if (this.Connection == null)
            {
                return(this.QueryMultipleImpl(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, true));
            }
            else
            {
                return(this.QueryMultipleImpl(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, false));
            }
        }
Exemple #16
0
        public async Task <TResult> QueryMapAsync <TResult>(Func <QueryReader, TResult> mapping, string sql, object objParameter = null, CommandType cmdType = CommandType.Text)
        {
            Type paramType = objParameter != null?objParameter.GetType() : null;

            int         cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);
            QueryReader reader   = null;

            if (this.Connection == null)
            {
                reader = await this.QueryMultipleImplAsync(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, true);
            }
            else
            {
                reader = await this.QueryMultipleImplAsync(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, false);
            }
            return(mapping(reader));
        }
Exemple #17
0
        public int ExecSql(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(this.ExecSqlImpl(cacheKey, sql, cmdType, objParameter));
        }
Exemple #18
0
        public async Task <int> UpdateAsync(string sql, TEntity entity = null)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(await this.ExecSqlImplAsync(cacheKey, sql, CommandType.Text, entity));
        }
Exemple #19
0
        public int Update(string sql, TEntity entity = null)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(this.ExecSqlImpl(cacheKey, sql, CommandType.Text, entity));
        }
Exemple #20
0
        public async Task <TEntity> QueryFirstAsync(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(await this.QueryFirstImplAsync <TEntity>(cacheKey, Mapper.EntityType, sql, cmdType, objParameter));
        }
Exemple #21
0
        public async Task <List <TTarget> > QueryAsync <TTarget>(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(await this.QueryImplAsync <TTarget>(cacheKey, typeof(TTarget), sql, cmdType, objParameter));
        }
Exemple #22
0
        public List <TEntity> Query(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(this.QueryImpl <TEntity>(cacheKey, Mapper.EntityType, sql, cmdType, objParameter));
        }
Exemple #23
0
        public async Task <int> ExecSqlAsync(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(await this.ExecSqlImplAsync(cacheKey, sql, cmdType, objParameter));
        }
Exemple #24
0
        public TTarget QueryFirst <TTarget>(string sql, TEntity objParameter = null, CommandType cmdType = CommandType.Text)
        {
            int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql);

            return(this.QueryFirstImpl <TTarget>(cacheKey, typeof(TTarget), sql, cmdType, objParameter));
        }