public static DEMOQLKTXEntities GetInstance() { if (dbContext == null) { dbContext = new DEMOQLKTXEntities(); } return(dbContext); }
public void saveConnectionstring(string yourInitialCatalog, string yourDataSource, string userName, string passWord) { DEMOQLKTXEntities selectedDb = MyDb.GetInstance(); selectedDb.ChangeDatabase(initialCatalog: yourInitialCatalog.Trim(), dataSource: yourDataSource.Trim(), userName, passWord); User firstUser = selectedDb.Users.FirstOrDefault(); if (firstUser == null) { MessageBox.Show("Error"); } // WriteAllText creates a file, writes the specified string to the file, // and then closes the file. You do NOT need to call Flush() or Close(). System.IO.File.WriteAllText("ConnectString.txt", selectedDb.Database.Connection.ConnectionString); }
public GenericUnitOfWork(DEMOQLKTXEntities entities) { this.entities = entities; }
public GenericUnitOfWork() { entities = new DEMOQLKTXEntities(); }