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

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