示例#1
0
        public IDbConnection CreateConnection()
        {
            if (_databaseKind == DatabaseKinds.SqlServer)
            {
                //return new SqlConnection(@"Data Source=akirapcwin7\sqlexpress;Initial Catalog=test;Integrated Security=True");
                //return new SqlConnection(@"Data Source=akawawin8\sqlserver2016;Initial Catalog=cplan_demo;Integrated Security=True");
                return(new SqlConnection(@"Data Source=localhost\sql2019;Initial Catalog=cplan_1000U;Integrated Security=True"));
            }
            else
            {
                IDbConnection connection;

                if (_sqliteDatabaseContext == null)
                {
                    _sqliteDatabaseContext = new SqliteDatabaseContext();

                    try
                    {
                        _sqliteDatabaseContext.Database.EnsureCreated();
                    }
                    catch
                    {
                    }
                }

                connection = new SqliteConnection(_sqliteDatabaseContext.GetConnectionString());

                return(connection);
            }
        }