public EFReturnValue SaveUpdateList <T1, T2>(List <T1> listEntity1, bool isSaveT1, List <T2> listEntity2, bool isSaveT2) where T1 : class where T2 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listEntity1 != null & listEntity2 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { listEntity1 = this.SetEntityPreparation <T1>(listEntity1, isSaveT1); listEntity2 = this.SetEntityPreparation <T2>(listEntity2, isSaveT2); if (isSaveT1) { context.Set <T1>().AddRange(listEntity1); } if (isSaveT2) { context.Set <T2>().AddRange(listEntity2); } if (!isSaveT1) { for (int i = 0; i < listEntity1.Count; i++) { List <PropertyInfo> colNotNullT1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(listEntity1[i]); context.Set <T1>().Attach(listEntity1[i]); context.Entry(listEntity1[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT1) { if (property != null) { context.Entry(listEntity1[i]).Property(property.Name).IsModified = true; } } } } if (!isSaveT2) { for (int i = 0; i < listEntity2.Count; i++) { List <PropertyInfo> colNotNullT2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(listEntity2[i]); context.Set <T2>().Attach(listEntity2[i]); context.Entry(listEntity2[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT2) { if (property != null) { context.Entry(listEntity2[i]).Property(property.Name).IsModified = true; } } } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listEntity1, listEntity2); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual EFReturnValue UpdateList <T1, T2, T3>(List <T1> listEntity1, List <T2> listEntity2, List <T3> listEntity3) where T1 : class where T2 : class where T3 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listEntity1.Count > 0 & listEntity2.Count > 0 & listEntity3.Count > 0) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { for (int i = 0; i < listEntity1.Count; i++) { T1 entity = listEntity1[i]; entity = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T1>(entity); var colNotNull = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity);//will update except activebool boolactive insertby insertbyid context.Set <T1>().Attach(entity); context.Entry(entity).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNull) { if (property != null) { context.Entry(entity).Property(property.Name).IsModified = true; } } } for (int i = 0; i < listEntity2.Count; i++) { T2 entity = listEntity2[i]; entity = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T2>(entity); var colNotNull = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity);//will update except activebool boolactive insertby insertbyid context.Set <T2>().Attach(entity); context.Entry(entity).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNull) { if (property != null) { context.Entry(entity).Property(property.Name).IsModified = true; } } } for (int i = 0; i < listEntity3.Count; i++) { T3 entity = listEntity3[i]; entity = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T3>(entity); var colNotNull = ColumnPropGet.GetInstance.GetPropertyColNotNull <T3>(entity);//will update except activebool boolactive insertby insertbyid context.Set <T3>().Attach(entity); context.Entry(entity).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNull) { if (property != null) { context.Entry(entity).Property(property.Name).IsModified = true; } } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listEntity1, listEntity2, listEntity3); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public EFReturnValue UpdateAll <T1, T2, T3, T4, T5>(T1 entity1, T2 entity2, T3 entity3, T4 entity4, T5 entity5) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null & entity3 != null & entity4 != null & entity5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { var cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T1>(entity1, out eFReturn); if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T2>(entity2, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T3>(entity3, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T4>(entity4, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T5>(entity5, out eFReturn); } if (cekIsContinue) { entity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T1>(entity1); entity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T2>(entity2); entity3 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T3>(entity3); entity4 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T4>(entity4); entity5 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T5>(entity5); context.Set <T1>().Attach(entity1); context.Set <T2>().Attach(entity2); context.Set <T3>().Attach(entity3); context.Set <T4>().Attach(entity4); context.Set <T5>().Attach(entity5); context.Entry(entity1).State = EntityState.Modified; context.Entry(entity2).State = EntityState.Modified; context.Entry(entity3).State = EntityState.Modified; context.Entry(entity4).State = EntityState.Modified; context.Entry(entity5).State = EntityState.Modified; hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1, entity2, entity3, entity4, entity5); } } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual async Task <EFReturnValue> DeleteActiveBoolListAsync <T1, T2, T3, T4, T5>(List <int> listIDIdentity1, List <int> listIDIdentity2, List <int> listIDIdentity3, List <int> listIDIdentity4, List <int> listIDIdentity5) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listIDIdentity1 != null & listIDIdentity2 != null & listIDIdentity3 != null & listIDIdentity4 != null & listIDIdentity5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { List <T1> listEntity1 = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T1>(listIDIdentity1); List <T2> listEntity2 = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T2>(listIDIdentity2); List <T3> listEntity3 = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T3>(listIDIdentity3); List <T4> listEntity4 = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T4>(listIDIdentity4); List <T5> listEntity5 = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T5>(listIDIdentity5); listEntity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T1>(listEntity1); listEntity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T2>(listEntity2); listEntity3 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T3>(listEntity3); listEntity4 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T4>(listEntity4); listEntity5 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T5>(listEntity5); foreach (var item in listEntity1) { var propUpdateDate1 = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool1 = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T1>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate1 != null) { context.Entry(item).Property(propUpdateDate1.Name).IsModified = true; } if (propActiveBool1 != null) { context.Entry(item).Property(propActiveBool1.Name).IsModified = true; } } foreach (var item in listEntity2) { var propUpdateDate2 = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool2 = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T2>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate2 != null) { context.Entry(item).Property(propUpdateDate2.Name).IsModified = true; } if (propActiveBool2 != null) { context.Entry(item).Property(propActiveBool2.Name).IsModified = true; } } foreach (var item in listEntity3) { var propUpdateDate3 = ColumnPropGet.GetInstance.GetColumnProps <T3>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool3 = ColumnPropGet.GetInstance.GetColumnProps <T3>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T3>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate3 != null) { context.Entry(item).Property(propUpdateDate3.Name).IsModified = true; } if (propActiveBool3 != null) { context.Entry(item).Property(propActiveBool3.Name).IsModified = true; } } foreach (var item in listEntity4) { var propUpdateDate4 = ColumnPropGet.GetInstance.GetColumnProps <T4>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool4 = ColumnPropGet.GetInstance.GetColumnProps <T4>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T4>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate4 != null) { context.Entry(item).Property(propUpdateDate4.Name).IsModified = true; } if (propActiveBool4 != null) { context.Entry(item).Property(propActiveBool4.Name).IsModified = true; } } foreach (var item in listEntity5) { var propUpdateDate5 = ColumnPropGet.GetInstance.GetColumnProps <T5>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool5 = ColumnPropGet.GetInstance.GetColumnProps <T5>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T5>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate5 != null) { context.Entry(item).Property(propUpdateDate5.Name).IsModified = true; } if (propActiveBool5 != null) { context.Entry(item).Property(propActiveBool5.Name).IsModified = true; } } hasil = await context.SaveChangesAsync().ConfigureAwait(false); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listEntity1, listIDIdentity2, listIDIdentity3, listIDIdentity4, listIDIdentity4, listIDIdentity5); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public EFReturnValue SaveUpdateDeleteActiveBool <T1, T2>(T1 entity1, EnumSaveUpdateDelete enumSUDT1, T2 entity2, EnumSaveUpdateDelete enumSUDT2) where T1 : class where T2 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { entity1 = this.SetEntityPreparation <T1>(entity1, enumSUDT1); entity2 = this.SetEntityPreparation <T2>(entity2, enumSUDT2); List <PropertyInfo> colNotNullT1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity1); List <PropertyInfo> colNotNullT2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity2); if (enumSUDT1 == EnumSaveUpdateDelete.Save) { context.Set <T1>().Add(entity1); } if (enumSUDT2 == EnumSaveUpdateDelete.Save) { context.Set <T2>().Add(entity2); } if (enumSUDT1 == EnumSaveUpdateDelete.Delete) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T1>().Attach(entity1); context.Entry(entity1).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(entity1).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(entity1).Property(propActiveBool.Name).IsModified = true; } } if (enumSUDT2 == EnumSaveUpdateDelete.Delete) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T2>().Attach(entity2); context.Entry(entity2).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(entity2).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(entity2).Property(propActiveBool.Name).IsModified = true; } } if (enumSUDT1 == EnumSaveUpdateDelete.Update) { context.Set <T1>().Attach(entity1); context.Entry(entity1).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT1) { if (property != null) { context.Entry(entity1).Property(property.Name).IsModified = true; } } } if (enumSUDT2 == EnumSaveUpdateDelete.Update) { context.Set <T2>().Attach(entity2); context.Entry(entity2).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT2) { if (property != null) { context.Entry(entity2).Property(property.Name).IsModified = true; } } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public EFReturnValue SaveUpdateDeleteList <T1, T2, T3, T4, T5>(List <T1> listEntity1, EnumSaveUpdateDelete enumSUDT1, List <T2> listEntity2, EnumSaveUpdateDelete enumSUDT2, List <T3> listEntity3, EnumSaveUpdateDelete enumSUDT3, List <T4> listEntity4, EnumSaveUpdateDelete enumSUDT4, List <T5> listEntity5, EnumSaveUpdateDelete enumSUDT5) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listEntity1 != null & listEntity2 != null & listEntity3 != null & listEntity4 != null & listEntity5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { listEntity1 = this.SetEntityPreparation <T1>(listEntity1, enumSUDT1); listEntity2 = this.SetEntityPreparation <T2>(listEntity2, enumSUDT2); listEntity3 = this.SetEntityPreparation <T3>(listEntity3, enumSUDT3); listEntity4 = this.SetEntityPreparation <T4>(listEntity4, enumSUDT4); listEntity5 = this.SetEntityPreparation <T5>(listEntity5, enumSUDT5); if (enumSUDT1 == EnumSaveUpdateDelete.Save) { context.Set <T1>().AddRange(listEntity1); } if (enumSUDT2 == EnumSaveUpdateDelete.Save) { context.Set <T2>().AddRange(listEntity2); } if (enumSUDT3 == EnumSaveUpdateDelete.Save) { context.Set <T3>().AddRange(listEntity3); } if (enumSUDT4 == EnumSaveUpdateDelete.Save) { context.Set <T4>().AddRange(listEntity4); } if (enumSUDT5 == EnumSaveUpdateDelete.Save) { context.Set <T5>().AddRange(listEntity5); } if (enumSUDT1 == EnumSaveUpdateDelete.Delete) { context.Set <T1>().AttachRange(listEntity1); context.Set <T1>().RemoveRange(listEntity1); } if (enumSUDT2 == EnumSaveUpdateDelete.Delete) { context.Set <T2>().AttachRange(listEntity2); context.Set <T2>().RemoveRange(listEntity2); } if (enumSUDT3 == EnumSaveUpdateDelete.Delete) { context.Set <T3>().AttachRange(listEntity3); context.Set <T3>().RemoveRange(listEntity3); } if (enumSUDT4 == EnumSaveUpdateDelete.Delete) { context.Set <T4>().AttachRange(listEntity4); context.Set <T4>().RemoveRange(listEntity4); } if (enumSUDT5 == EnumSaveUpdateDelete.Delete) { context.Set <T5>().AttachRange(listEntity5); context.Set <T5>().RemoveRange(listEntity5); } if (enumSUDT1 == EnumSaveUpdateDelete.Update) { for (int i = 0; i < listEntity1.Count; i++) { List <PropertyInfo> colNotNullT1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(listEntity1[i]); context.Set <T1>().Attach(listEntity1[i]); context.Entry(listEntity1[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT1) { if (property != null) { context.Entry(listEntity1[i]).Property(property.Name).IsModified = true; } } } } if (enumSUDT2 == EnumSaveUpdateDelete.Update) { for (int i = 0; i < listEntity2.Count; i++) { List <PropertyInfo> colNotNullT2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(listEntity2[i]); context.Set <T2>().Attach(listEntity2[i]); context.Entry(listEntity2[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT2) { if (property != null) { context.Entry(listEntity2[i]).Property(property.Name).IsModified = true; } } } } if (enumSUDT3 == EnumSaveUpdateDelete.Update) { for (int i = 0; i < listEntity3.Count; i++) { List <PropertyInfo> colNotNullT3 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T3>(listEntity3[i]); context.Set <T3>().Attach(listEntity3[i]); context.Entry(listEntity3[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT3) { if (property != null) { context.Entry(listEntity3[i]).Property(property.Name).IsModified = true; } } } } if (enumSUDT4 == EnumSaveUpdateDelete.Update) { for (int i = 0; i < listEntity4.Count; i++) { List <PropertyInfo> colNotNullT4 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T4>(listEntity4[i]); context.Set <T4>().Attach(listEntity4[i]); context.Entry(listEntity4[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT4) { if (property != null) { context.Entry(listEntity4[i]).Property(property.Name).IsModified = true; } } } } if (enumSUDT5 == EnumSaveUpdateDelete.Update) { for (int i = 0; i < listEntity5.Count; i++) { List <PropertyInfo> colNotNullT5 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T5>(listEntity5[i]); context.Set <T5>().Attach(listEntity5[i]); context.Entry(listEntity5[i]).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT5) { if (property != null) { context.Entry(listEntity5[i]).Property(property.Name).IsModified = true; } } } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listEntity1, listEntity2, listEntity3, listEntity4, listEntity5); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public async Task <EFReturnValue> SaveUpdateDeleteAsync <T1, T2, T3, T4>(T1 entity1, EnumSaveUpdateDelete enumSUDT1, T2 entity2, EnumSaveUpdateDelete enumSUDT2, T3 entity3, EnumSaveUpdateDelete enumSUDT3, T4 entity4, EnumSaveUpdateDelete enumSUDT4) where T1 : class where T2 : class where T3 : class where T4 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null & entity3 != null & entity4 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { entity1 = this.SetEntityPreparation <T1>(entity1, enumSUDT1); entity2 = this.SetEntityPreparation <T2>(entity2, enumSUDT2); entity3 = this.SetEntityPreparation <T3>(entity3, enumSUDT3); entity4 = this.SetEntityPreparation <T4>(entity4, enumSUDT4); List <PropertyInfo> colNotNullT1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity1); List <PropertyInfo> colNotNullT2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity2); List <PropertyInfo> colNotNullT3 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T3>(entity3); List <PropertyInfo> colNotNullT4 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T4>(entity4); if (enumSUDT1 == EnumSaveUpdateDelete.Save) { await context.Set <T1>().AddAsync(entity1); } if (enumSUDT2 == EnumSaveUpdateDelete.Save) { await context.Set <T2>().AddAsync(entity2); } if (enumSUDT3 == EnumSaveUpdateDelete.Save) { await context.Set <T3>().AddAsync(entity3); } if (enumSUDT4 == EnumSaveUpdateDelete.Save) { await context.Set <T4>().AddAsync(entity4); } if (enumSUDT1 == EnumSaveUpdateDelete.Delete) { context.Set <T1>().Attach(entity1); context.Set <T1>().Remove(entity1); } if (enumSUDT2 == EnumSaveUpdateDelete.Delete) { context.Set <T2>().Attach(entity2); context.Set <T2>().Remove(entity2); } if (enumSUDT3 == EnumSaveUpdateDelete.Delete) { context.Set <T3>().Attach(entity3); context.Set <T3>().Remove(entity3); } if (enumSUDT4 == EnumSaveUpdateDelete.Delete) { context.Set <T4>().Attach(entity4); context.Set <T4>().Remove(entity4); } if (enumSUDT1 == EnumSaveUpdateDelete.Update) { context.Set <T1>().Attach(entity1); context.Entry(entity1).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT1) { if (property != null) { context.Entry(entity1).Property(property.Name).IsModified = true; } } } if (enumSUDT2 == EnumSaveUpdateDelete.Update) { context.Set <T2>().Attach(entity2); context.Entry(entity2).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT2) { if (property != null) { context.Entry(entity2).Property(property.Name).IsModified = true; } } } if (enumSUDT3 == EnumSaveUpdateDelete.Update) { context.Set <T3>().Attach(entity3); context.Entry(entity3).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT3) { if (property != null) { context.Entry(entity3).Property(property.Name).IsModified = true; } } } if (enumSUDT4 == EnumSaveUpdateDelete.Update) { context.Set <T4>().Attach(entity4); context.Entry(entity4).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT4) { if (property != null) { context.Entry(entity4).Property(property.Name).IsModified = true; } } } hasil = await context.SaveChangesAsync().ConfigureAwait(false); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1, entity2, entity3, entity4); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public EFReturnValue SaveUpdate <T1, T2, T3, T4, T5>(T1 entity1, bool isSaveT1, T2 entity2, bool isSaveT2, T3 entity3, bool isSaveT3, T4 entity4, bool isSaveT4, T5 entity5, bool isSaveT5) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null & entity3 != null & entity4 != null & entity5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { entity1 = this.SetEntityPreparation <T1>(entity1, isSaveT1); entity2 = this.SetEntityPreparation <T2>(entity2, isSaveT2); entity3 = this.SetEntityPreparation <T3>(entity3, isSaveT3); entity4 = this.SetEntityPreparation <T4>(entity4, isSaveT4); entity5 = this.SetEntityPreparation <T5>(entity5, isSaveT5); List <PropertyInfo> colNotNullT1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity1); List <PropertyInfo> colNotNullT2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity2); List <PropertyInfo> colNotNullT3 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T3>(entity3); List <PropertyInfo> colNotNullT4 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T4>(entity4); List <PropertyInfo> colNotNullT5 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T5>(entity5); if (isSaveT1) { context.Set <T1>().Add(entity1); } if (isSaveT2) { context.Set <T2>().Add(entity2); } if (isSaveT3) { context.Set <T3>().Add(entity3); } if (isSaveT4) { context.Set <T4>().Add(entity4); } if (isSaveT5) { context.Set <T5>().Add(entity5); } if (!isSaveT1) { context.Set <T1>().Attach(entity1); context.Entry(entity1).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT1) { if (property != null) { context.Entry(entity1).Property(property.Name).IsModified = true; } } } if (!isSaveT2) { context.Set <T2>().Attach(entity2); context.Entry(entity2).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT2) { if (property != null) { context.Entry(entity2).Property(property.Name).IsModified = true; } } } if (!isSaveT3) { context.Set <T3>().Attach(entity3); context.Entry(entity3).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT3) { if (property != null) { context.Entry(entity3).Property(property.Name).IsModified = true; } } } if (!isSaveT4) { context.Set <T4>().Attach(entity4); context.Entry(entity4).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT4) { if (property != null) { context.Entry(entity4).Property(property.Name).IsModified = true; } } } if (!isSaveT5) { context.Set <T5>().Attach(entity5); context.Entry(entity5).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNullT5) { if (property != null) { context.Entry(entity5).Property(property.Name).IsModified = true; } } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1, entity2, entity3, entity4, entity5); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual async Task <EFReturnValue> UpdateAsync <T1, T2>(T1 entity1, T2 entity2) where T1 : class where T2 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { var cekIsContinue = await multiple.IsContinueUpdateAfterMultiplePKAsync <T1>(entity1); if (cekIsContinue) { cekIsContinue = await multiple.IsContinueUpdateAfterMultiplePKAsync <T2>(entity2); } if (cekIsContinue) { entity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T1>(entity1); entity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T2>(entity2); var colNotNull1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity1); //will update except activebool boolactive insertby insertbyid var colNotNull2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity2); //will update except activebool boolactive insertby insertbyid context.Set <T1>().Attach(entity1); context.Set <T2>().Attach(entity2); context.Entry(entity1).State = EntityState.Unchanged; context.Entry(entity2).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity1).Property(property.Name).IsModified = true; } } foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity2).Property(property.Name).IsModified = true; } } hasil = await context.SaveChangesAsync().ConfigureAwait(false); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1, entity2); } else { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, this.multipleErrorMessage); } } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual EFReturnValue DeleteHeaderDetailActiveBool <T, T1, T2>(int IDIdentity, string idReferenceColName) where T : class where T1 : class where T2 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (IDIdentity > 0 & !string.IsNullOrEmpty(idReferenceColName)) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { T entity = Activator.CreateInstance <T>(); ColumnPropSet.GetInstance.SetColValueIdentityColumn <T>(entity, IDIdentity); List <T1> listEntity1 = this.getListData <T1>(IDIdentity, idReferenceColName); List <T2> listEntity2 = this.getListData <T2>(IDIdentity, idReferenceColName); entity = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T>(entity); listEntity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T1>(listEntity1); listEntity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T2>(listEntity2); var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayActiveBool); var propUpdateDate1 = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool1 = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayActiveBool); var propUpdateDate2 = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool2 = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T>().Attach(entity); context.Set <List <T1> >().Attach(listEntity1); context.Set <List <T2> >().Attach(listEntity2); context.Entry(entity).State = EntityState.Unchanged; context.Entry(listEntity1).State = EntityState.Unchanged; context.Entry(listEntity2).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(entity).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(entity).Property(propActiveBool.Name).IsModified = true; } context.Entry(listEntity1).Property(propUpdateDate.Name).IsModified = propUpdateDate != null ? true : false; context.Entry(listEntity1).Property(propActiveBool.Name).IsModified = propActiveBool != null ? true : false; context.Entry(listEntity2).Property(propUpdateDate.Name).IsModified = propUpdateDate != null ? true : false; context.Entry(listEntity2).Property(propActiveBool.Name).IsModified = propActiveBool != null ? true : false; hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity, listEntity1); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual EFReturnValue DeleteHeaderDetailActiveBoolList <T, T1, T2, T3, T4, T5>(List <int> listIDIdentity, string idReferenceColName) where T : class where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listIDIdentity.Count > 0 & !string.IsNullOrEmpty(idReferenceColName)) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { List <T> listEntity = ColumnPropGet.GetInstance.GetInstanceWithIDColumnList <T>(listIDIdentity); List <T1> listEntity1 = this.GetListData <T1>(listIDIdentity, idReferenceColName); List <T2> listEntity2 = this.GetListData <T2>(listIDIdentity, idReferenceColName); List <T3> listEntity3 = this.GetListData <T3>(listIDIdentity, idReferenceColName); List <T4> listEntity4 = this.GetListData <T4>(listIDIdentity, idReferenceColName); List <T5> listEntity5 = this.GetListData <T5>(listIDIdentity, idReferenceColName); listEntity = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T>(listEntity); listEntity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T1>(listEntity1); listEntity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T2>(listEntity2); listEntity3 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T3>(listEntity3); listEntity4 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T4>(listEntity4); listEntity5 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["delete"].SetPreparationEntity <T5>(listEntity5); foreach (var item in listEntity) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } foreach (var item in listEntity1) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T1>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T1>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } foreach (var item in listEntity2) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T2>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T2>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } foreach (var item in listEntity3) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T3>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T3>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T3>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } foreach (var item in listEntity4) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T4>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T4>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T4>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } foreach (var item in listEntity5) { var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <T5>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <T5>(MiscClass.MiscClass.ArrayActiveBool); context.Set <T5>().Attach(item); context.Entry(item).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(item).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(item).Property(propActiveBool.Name).IsModified = true; } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listEntity, listEntity1, listEntity2, listEntity3, listEntity4, listEntity5); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public EFReturnValue Update <T1, T2, T3, T4, T5>(T1 entity1, T2 entity2, T3 entity3, T4 entity4, T5 entity5) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (entity1 != null & entity2 != null & entity3 != null & entity4 != null & entity5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { var cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T1>(entity1, out eFReturn); if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T2>(entity2, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T3>(entity3, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T4>(entity4, out eFReturn); } if (cekIsContinue) { cekIsContinue = multiple.IsContinueUpdateAfterMultiplePK <T5>(entity5, out eFReturn); } if (cekIsContinue) { entity1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T1>(entity1); entity2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T2>(entity2); entity3 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T3>(entity3); entity4 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T4>(entity4); entity5 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["updatedefined"].SetPreparationEntity <T5>(entity5); var colNotNull1 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T1>(entity1); //will update except activebool boolactive insertby insertbyid var colNotNull2 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T2>(entity2); //will update except activebool boolactive insertby insertbyid var colNotNull3 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T3>(entity3); //will update except activebool boolactive insertby insertbyid var colNotNull4 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T4>(entity4); //will update except activebool boolactive insertby insertbyid var colNotNull5 = ColumnPropGet.GetInstance.GetPropertyColNotNull <T5>(entity5); //will update except activebool boolactive insertby insertbyid context.Set <T1>().Attach(entity1); context.Set <T2>().Attach(entity2); context.Set <T3>().Attach(entity3); context.Set <T4>().Attach(entity4); context.Set <T5>().Attach(entity5); context.Entry(entity1).State = EntityState.Unchanged; context.Entry(entity2).State = EntityState.Unchanged; context.Entry(entity3).State = EntityState.Unchanged; context.Entry(entity4).State = EntityState.Unchanged; context.Entry(entity5).State = EntityState.Unchanged; foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity1).Property(property.Name).IsModified = true; } } foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity2).Property(property.Name).IsModified = true; } } foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity3).Property(property.Name).IsModified = true; } } foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity4).Property(property.Name).IsModified = true; } } foreach (PropertyInfo property in colNotNull1) { if (property != null) { context.Entry(entity5).Property(property.Name).IsModified = true; } } hasil = context.SaveChanges(); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, entity1, entity2, entity3, entity4, entity5); } } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }
public virtual async Task <EFReturnValue> DeleteSaveActiveBoolListAsync <TDelete, T1, T2, T3, T4, T5>(List <SearchField> deleteParameters, List <T1> listEntitySave1, List <T2> listEntitySave2, List <T3> listEntitySave3, List <T4> listEntitySave4, List <T5> listEntitySave5) where TDelete : class where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class { int hasil = 0; eFReturn = new EFReturnValue { IsSuccessConnection = false, IsSuccessQuery = false, ErrorMessage = ErrorMessage.EntityCannotBeNull, ReturnValue = null }; if (listEntitySave1 != null & listEntitySave2 != null & listEntitySave3 != null & listEntitySave4 != null & listEntitySave5 != null) { using (var context = DBContextBantuan.GetInstance.CreateConnectionContext()) { using (var contextTrans = context.Database.BeginTransaction()) { try { List <TDelete> listDelete = new List <TDelete>(); var listDeleteRV = RepoList.GetInstance.ListData <TDelete>(deleteParameters); if (listDeleteRV.IsSuccessConnection & listDeleteRV.IsSuccessQuery) { listDelete = (List <TDelete>)listDeleteRV.ReturnValue; } listEntitySave1 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["save"].SetPreparationEntity <T1>(listEntitySave1); listEntitySave2 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["save"].SetPreparationEntity <T2>(listEntitySave2); listEntitySave3 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["save"].SetPreparationEntity <T3>(listEntitySave3); listEntitySave4 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["save"].SetPreparationEntity <T4>(listEntitySave4); listEntitySave5 = EntityPreparationBantuan.GetInstance.DictEntityPreparation["save"].SetPreparationEntity <T5>(listEntitySave5); listDelete = EntityPreparationBantuan.GetInstance.DictEntityPreparation["deleteactivebool"].SetPreparationEntity <TDelete>(listDelete); var propUpdateDate = ColumnPropGet.GetInstance.GetColumnProps <TDelete>(MiscClass.MiscClass.ArrayUpdateDate); var propActiveBool = ColumnPropGet.GetInstance.GetColumnProps <TDelete>(MiscClass.MiscClass.ArrayActiveBool); context.Set <TDelete>().AttachRange(listDelete); context.Entry(listDelete).State = EntityState.Unchanged; if (propUpdateDate != null) { context.Entry(listDelete).Property(propUpdateDate.Name).IsModified = true; } if (propActiveBool != null) { context.Entry(listDelete).Property(propActiveBool.Name).IsModified = true; } foreach (var item in listEntitySave1) { context.Set <T1>().Add(item); } foreach (var item in listEntitySave2) { context.Set <T2>().Add(item); } foreach (var item in listEntitySave3) { context.Set <T3>().Add(item); } foreach (var item in listEntitySave4) { context.Set <T4>().Add(item); } foreach (var item in listEntitySave5) { context.Set <T5>().Add(item); } hasil = await context.SaveChangesAsync().ConfigureAwait(false); contextTrans.Commit(); eFReturn = eFReturn.SetEFReturnValue(eFReturn, true, hasil, listDelete, listEntitySave1, listEntitySave2, listEntitySave3, listEntitySave4, listEntitySave5); } catch (Exception ex) { eFReturn = eFReturn.SetEFReturnValue(eFReturn, false, 0, ex.Message); contextTrans.Rollback(); } } } } return(eFReturn); }