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