示例#1
0
        private void InitializeSettingTable()
        {
            string dbName = "receptionist.db3";

            ILocalStorageService storageService   = ServiceProvider.GetService <ILocalStorageService>();
            IActivatorService    activatorService = ServiceProvider.GetService <IActivatorService>();
            var factory = activatorService.CreateInstance <Func <string, ISQLiteConnection> >();

            ISQLiteConnection db = factory(storageService.GetFilePath(dbName, LocalFolderKind.Data));

            if (!db.TableExists <GeneralSetting>())
            {
                db.CreateTable <GeneralSetting>();
            }
            //else
            //    db.MigrateTable<Setting>();

            if (db.Table <GeneralSetting>().ToList().Count == 0)
            {
                List <GeneralSetting> generalsetting = new List <GeneralSetting>();
                generalsetting.Add(new GeneralSetting()
                {
                    SettingId = Guid.NewGuid(), GeneralName = "barcode"
                });
                db.InsertAll(generalsetting);
            }
        }