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