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