//シングルトン private DatabaseOperation() { //接続文字列の生成 basePath = Directory.GetCurrentDirectory() + @"\ApplicationDatabase.mdf"; connStr = @"Data Source=(LocalDB)\v11.0;Integrated Security=True;Connection Timeout=30;AttachDbFilename=""" + basePath + @""";"; //データベース接続 RetryHelper.Retry(() => { database = new ApplicationDataClassesDataContext(connStr); }, ex => ExceptionDispatchInfo.Capture(ex).Throw(), ex => ex is SqlException); }
public RegistrationDateViewModel() { //データベース接続 DatabaseOperation dbOperator = DatabaseOperation.Instance; database = dbOperator.GetConnectionedDataContext; }