public async Task <KhoTaiKhoan> UpdatePartial(KhoTaiKhoan nuocsx, params string[] field) { var a = await WithConnection(async c => { KhoTaiKhoan obj = await c.GetAsync(nuocsx); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", nuocsx.TaiKhoanId.ToString())); } var list = field.ToList(); var partialUpdateMapping = OrmConfiguration .GetDefaultEntityMapping <KhoTaiKhoan>() .Clone() .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true, list.ToArray()); var result = await c.UpdateAsync(nuocsx, statement => statement.WithEntityMappingOverride(partialUpdateMapping)); if (result != true) { throw new Exception("Update Fail"); } return(nuocsx); }); return(a); }
public async Task <KhoTaiKhoan> Insert(KhoTaiKhoan nuocsx) { return(await WithConnection(async c => { await c.InsertAsync(nuocsx); if (nuocsx.TaiKhoanId == 0) { throw new Exception("Insert Fail"); } return nuocsx; })); }
public async Task <KhoTaiKhoan> Update(KhoTaiKhoan nuocsx) { return(await WithConnection(async c => { KhoTaiKhoan obj = await c.GetAsync(nuocsx); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", nuocsx.TaiKhoanId.ToString())); } var result = await c.UpdateAsync(nuocsx); if (result != true) { throw new Exception("Update Fail"); } return nuocsx; })); }