示例#1
0
        public static void MysqlDatabase()
        {
            string connection;

            // connection = "server=DS218P;database=room;user=room;password=talky-polka-pause6-3selector-countable-Freebie9;port=3307";
            Windows.Storage.ApplicationDataCompositeValue composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["mysqlSettings"];
            if (composite == null)
            {
                SqliteDatabase();
            }
            else
            {
                connection = "server=" + composite["server"].ToString() + ";"
                             + "database=" + composite["database"].ToString() + ";"
                             + "user="******"user"].ToString() + ";"
                             + "password="******"password"].ToString() + ";"
                             + "port=" + composite["port"].ToString() + ";"

                ;

                DbContextOptionsBuilder <Room5Context> dbOptions = new DbContextOptionsBuilder <Room5Context>().UseMySql(connection,
                                                                                                                         mysqlOptions => { });

                Repository = new SQLRoom5Repository(dbOptions);
            }
        }
示例#2
0
        public static void SqliteDatabase()
        {
            // string demoDatabasePath = Package.Current.InstalledLocation.Path + @"\Assets\Repository.db";

            //funktioniert frühestens mit ef core 3.1.4
            //   string databasePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\room5\Room5.db";

            /* if (!File.Exists(databasePath))
             * {
             *   File.Copy(demoDatabasePath, databasePath);
             * }*/
            DatabasePath = ApplicationData.Current.LocalFolder.Path + @"\Room5.db";
            DbOptions    = new DbContextOptionsBuilder <Room5Context>().UseSqlite("Data Source=" + DatabasePath);
            Repository   = new SQLRoom5Repository(DbOptions);
        }