public DataOperator(string pathToDB = null) { string fullPath = System.IO.Directory.GetCurrentDirectory(); int carefa = fullPath.IndexOf("\\PT_Task2\\"); fullPath = fullPath.Substring(0, carefa + 10); if (pathToDB == null) { fullPath += "PT_Task2_Data\\DB.mdf"; } else { fullPath += pathToDB; } string connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;"; connectionString += "AttachDbFilename="; connectionString += fullPath; connectionString += ";Integrated Security=True;Connect Timeout=30"; this.connectionString = connectionString; this.context = new DB_LinkDataContext(connectionString); }
public void RefreshTheDatabase() { this.context = new DB_LinkDataContext(this.connectionString); }