public override Task OnActivateAsync() { return(RayTask.Execute(() => { return base.OnActivateAsync(); })); }
public Task DeleteAsync(K id) { return(RayTask.Execute(async() => { using (var conn = tableInfo.CreateConnection()) { await conn.ExecuteAsync(deleteSql, new { StateId = id }); } })); }
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() }); } } })); }
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); }