Exemple #1
0
 public override Task OnActivateAsync()
 {
     return(RayTask.Execute(() =>
     {
         return base.OnActivateAsync();
     }));
 }
Exemple #2
0
 public Task DeleteAsync(K id)
 {
     return(RayTask.Execute(async() =>
     {
         using (var conn = tableInfo.CreateConnection())
         {
             await conn.ExecuteAsync(deleteSql, new { StateId = id });
         }
     }));
 }
Exemple #3
0
 public Task UpdateAsync(T data)
 {
     return(RayTask.Execute(async() =>
     {
         using (var ms = new PooledMemoryStream())
         {
             Serializer.Serialize <T>(ms, data);
             using (var connection = tableInfo.CreateConnection())
             {
                 await connection.ExecuteAsync(updateSql, new { data.StateId, Data = ms.ToArray() });
             }
         }
     }));
 }
Exemple #4
0
        public async Task <T> GetByIdAsync(K id)
        {
            byte[] state = await RayTask.Execute <byte[]>(async() =>
            {
                using (var conn = tableInfo.CreateConnection())
                {
                    return(await conn.ExecuteScalarAsync <byte[]>(getByIdSql, new { StateId = id }));
                }
            });

            if (state != null)
            {
                using (var ms = new MemoryStream(state))
                {
                    return(Serializer.Deserialize <T>(ms));
                }
            }
            return(null);
        }