///<summary> ///Add rows to DataBase /// </summary> public void AddRecords(IEnumerable <NumberValueEntity> tableStringParam) { using (NumberValueContext nvc = new NumberValueContext()) { try { nvc.NumberValue.AddRange(tableStringParam); nvc.SaveChanges(); }catch (Exception ex) { throw new Exception(ex.Message); } } }
/// <summary> /// Delete rows from DataBase /// </summary> /// <param name="entitiesToRemove">Entities to remove from table</param> public void DeleteRecords(IEnumerable <NumberValueEntity> entitiesToRemove) { using (NumberValueContext nvc = new NumberValueContext()) { try { nvc.NumberValue.RemoveRange(entitiesToRemove); nvc.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } } }
/// <summary> /// Update records /// </summary> /// <param name="recordsToUpdate"> Records to update </param> public void UpdateRecords(IEnumerable <NumberValueEntity> recordsToUpdate) { using (NumberValueContext nvc = new NumberValueContext()) { try { foreach (NumberValueEntity n in recordsToUpdate) { nvc.NumberValue.Find(n.NumberId).Value = n.Value; } nvc.SaveChanges(); }catch (Exception ex) { throw new Exception(ex.Message); } } }