Exemple #1
0
        public static DEMOQLKTXEntities GetInstance()
        {
            if (dbContext == null)
            {
                dbContext = new DEMOQLKTXEntities();
            }

            return(dbContext);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public GenericUnitOfWork(DEMOQLKTXEntities entities)
 {
     this.entities = entities;
 }
Exemple #4
0
 public GenericUnitOfWork()
 {
     entities = new DEMOQLKTXEntities();
 }