public Task DeleteAsync(K id) { return(SQLTask.SQLTaskExecute(async() => { using (var conn = tableInfo.CreateConnection()) { await conn.ExecuteAsync(deleteSql, new { StateId = id }); } })); }
public Task UpdateAsync(T data) { return(SQLTask.SQLTaskExecute(async() => { using (MemoryStream ms = new MemoryStream()) { 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 SQLTask.SQLTaskExecute <byte[]>(async() => { using (var conn = tableInfo.CreateConnection()) { return(await conn.ExecuteScalarAsync <byte[]>(getByIdSql, new { StateId = id })); } }); if (state != null) { using (MemoryStream ms = new MemoryStream(state)) { return(Serializer.Deserialize <T>(ms)); } } return(null); }