Exemplo n.º 1
0
        public async Task <TTarget> QueryMapAsync <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 = await this.QueryMultipleImplAsync <TTarget>(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, true);
            }
            else
            {
                reader = await this.QueryMultipleImplAsync <TTarget>(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, false);
            }
            return(mapping(reader));
        }
Exemplo n.º 2
0
        public TResult QueryMap <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 = this.QueryMultipleImpl(cacheKey, sql, this.Provider.CreateConnection(this.ConnString), null, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, true);
            }
            else
            {
                reader = this.QueryMultipleImpl(cacheKey, sql, this.Connection, this.Transaction, cmdType, CommandBehavior.SequentialAccess, objParameter, paramType, false);
            }
            return(mapping(reader));
        }