public async Task <KhoNuocSanXuat> UpdatePartial(KhoNuocSanXuat nuocsx, params string[] field) { var a = await WithConnection(async c => { KhoNuocSanXuat obj = await c.GetAsync(nuocsx); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", nuocsx.NuocSanXuatId.ToString())); } var list = field.ToList(); var partialUpdateMapping = OrmConfiguration .GetDefaultEntityMapping <KhoNuocSanXuat>() .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 <KhoNuocSanXuat> Insert(KhoNuocSanXuat nuocsx) { return(await WithConnection(async c => { await c.InsertAsync(nuocsx); if (nuocsx.NuocSanXuatId == 0) { throw new Exception("Insert Fail"); } return nuocsx; })); }
public async Task <KhoNuocSanXuat> Update(KhoNuocSanXuat nuocsx) { return(await WithConnection(async c => { KhoNuocSanXuat obj = await c.GetAsync(nuocsx); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", nuocsx.NuocSanXuatId.ToString())); } var result = await c.UpdateAsync(nuocsx); if (result != true) { throw new Exception("Update Fail"); } return nuocsx; })); }