예제 #1
0
 public async Task QuerySingleAsync()
 {
     RequestContext context = new RequestContext
     {
         Scope   = Scope,
         SqlId   = "GetEntity",
         Request = new { Id = 2 }
     };
     var user = await _sqlMapper.QuerySingleAsync <T_Entity>(context);
 }
예제 #2
0
        public static Task <T> QuerySingleAsync <T>(this ISmartSqlMapper sqlMapper, string fullSqlId, dynamic @params, DataSourceChoice sourceChoice)
        {
            EnsurePoint(ref fullSqlId);

            return(sqlMapper.QuerySingleAsync <T>(new RequestContext()
            {
                Scope = fullSqlId.Split('.')[0],
                SqlId = fullSqlId.Split('.')[1],
                Request = @params
            }, sourceChoice));
        }
예제 #3
0
        public async Task TransactionAsync()
        {
            try
            {
                _sqlMapper.BeginTransaction();
                var entity = await _sqlMapper.QuerySingleAsync <T_Entity>(new RequestContext
                {
                    Scope   = Scope,
                    SqlId   = "GetEntity",
                    Request = new { Id = 8 }
                });
                await InsertAsync();
                await InsertAsync();
                await InsertAsync();

                _sqlMapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                _sqlMapper.RollbackTransaction();
                throw ex;
            }
        }
예제 #4
0
 public Task <T> QuerySingleAsync <T>(RequestContext context)
 {
     return(MapperInstance.QuerySingleAsync <T>(context));
 }
예제 #5
0
 public Task <T> QuerySingleAsync <T>(RequestContext context)
 {
     return(SqlMapper.QuerySingleAsync <T>(context));
 }