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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); } }
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)); }
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)); } }
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)); }
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)); }
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)); }
public int Update(string sql, TEntity entity = null) { int cacheKey = RepositoryHelper.GetHashKey(this.ConnString, sql); return(this.ExecSqlImpl(cacheKey, sql, CommandType.Text, entity)); }
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)); }
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)); }
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)); }
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)); }
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)); }