public int InsertLabel(List <t_labels> lists) { int result = 0; using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (ERP2008Entities erp2008 = new ERP2008Entities()) { try { foreach (t_labels labels in lists) { erp2008.t_labels.Add(labels); if (erp2008.SaveChanges() <= 0) { throw new Exception(); } } scope.Complete(); result = 1; } catch (Exception) { scope.Dispose(); result = 0; } } } return(result); }
public int InsertLabel(Entity.t_labels label) { using (ERP2008Entities erp2008 = new ERP2008Entities()) { erp2008.t_labels.Add(label); return(erp2008.SaveChanges()); } }