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