public static InOrderPos NewACObject(MyCompanyDB dbApp, IACObject parentACObject) { InOrderPos entity = new InOrderPos(); entity.InOrderPosID = Guid.NewGuid(); entity.DefaultValuesACObject(); InOrder inOrder = parentACObject as InOrder; if (inOrder != null) { if (inOrder.EntityState != System.Data.EntityState.Added && inOrder.InOrderPos_InOrder != null && inOrder.InOrderPos_InOrder.Any()) { entity.Sequence = inOrder.InOrderPos_InOrder.Select(c => c.Sequence).Max() + 1; } else { entity.Sequence = 1; } entity.InOrder = inOrder; inOrder.InOrderPos_InOrder.Add(entity); } entity.SetInsertAndUpdateInfo(Database.Initials, dbApp); return(entity); }
public static Material NewACObject(MyCompanyDB dbApp, IACObject parentACObject) { Material entity = new Material(); entity.MaterialID = Guid.NewGuid(); entity.DefaultValuesACObject(); entity.SetInsertAndUpdateInfo(Database.Initials, dbApp); return(entity); }
public static InOrder NewACObject(MyCompanyDB dbApp, IACObject parentACObject, string secondaryKey) { InOrder entity = new InOrder(); entity.InOrderID = Guid.NewGuid(); entity.DefaultValuesACObject(); entity.InOrderDate = DateTime.Now; entity.InOrderNo = secondaryKey; entity.SetInsertAndUpdateInfo(Database.Initials, dbApp); return(entity); }
public static void InitializeDBOnStartup() { if (_AppDBOnStartupInitialized) { return; } _AppDBOnStartupInitialized = true; using (MyCompanyDB dbApp = new MyCompanyDB()) { dbApp.Material.FirstOrDefault(); } }