当前位置: 首页>>代码示例>>C#>>正文


C# SQLite.SQLiteConnection.CreateTable方法代码示例

本文整理汇总了C#中SQLite.SQLiteConnection.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# SQLite.SQLiteConnection.CreateTable方法的具体用法?C# SQLite.SQLiteConnection.CreateTable怎么用?C# SQLite.SQLiteConnection.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite.SQLiteConnection的用法示例。


在下文中一共展示了SQLite.SQLiteConnection.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connection

        public static SQLite.SQLiteConnection Connection()
        {
            var conn = new SQLite.SQLiteConnection(DBPath);
            if (!Initialized)
            {
                conn.CreateTable<Car.Car>();
                conn.CreateTable<Fillup.Fillup>();
                conn.CreateTable<Maintenance.Maintenance>();
                conn.CreateTable<Reminder.Reminder>();

                var cars = conn.Table<Car.Car>();

                if (cars.Count() == 0)
                {
                    Car.Car car = new Car.Car();
                    conn.Insert(car);
                }

                var firstCar = cars.First();

                if (cars.Where(vehicle => vehicle.ID == Settings.CurrentCarID).Count() == 0)
                    Settings.CurrentCarID = firstCar.ID;




                Initialized = true;
            }
            return conn;
        }
开发者ID:BenjaminChambers,项目名称:Open-Road,代码行数:30,代码来源:Database.cs

示例2: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Get a reference to the SQLite database
                this.DBPath = Path.Combine(
                    Windows.Storage.ApplicationData.Current.LocalFolder.Path, "budget.sqlite");

                // Initialize the database if necessary
                using (var db = new SQLite.SQLiteConnection(this.DBPath))
                {
                    // Create the tables if they don't exist
                    db.CreateTable<Budget>();
                    db.CreateTable<BudgetEnvelope>();
                    db.CreateTable<Account>();
                    db.CreateTable<Transaction>();

                    db.DeleteAll<Budget>();

                    db.Insert(new Budget()
                    {
                        Id = 1,
                        PaycheckAmount = 1000.0f,
                        Frequency = PaycheckFrequency.SemiMonthly,
                        Name = "My New Budget"
                    });

                    Budget b = db.Table<Budget>().First();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
开发者ID:danwkennedy,项目名称:BudgetHelper,代码行数:65,代码来源:App.xaml.cs

示例3: CreateTable

		private void CreateTable()
		{
			using (var conn = new SQLite.SQLiteConnection(GetDatabasePath()))
			{
				conn.CreateTable<Person>();
			}
		}
开发者ID:Tryan18,项目名称:XAMARIN,代码行数:7,代码来源:ManagePersons.cs

示例4: btnAdd_Click

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {

            if (FieldValidationExtensions.GetIsValid(AddressbookUserName) && FieldValidationExtensions.GetIsValid(AddressbookEmail))
            {

                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable<AddressBookEntree>();

                    User addressbookuser = new User();
                    addressbookuser.UserName = AddressbookUserName.Text;
                    addressbookuser.EmailAddress = AddressbookEmail.Text;

                    db.RunInTransaction(() =>
                    {
                        db.Insert(addressbookuser);

                        db.Insert(new AddressBookEntree() { OwnerUserID = App.loggedInUser.Id, EntreeUserID = addressbookuser.Id });
                    });
                }

            }

            this.Frame.Navigate(typeof(Dashboard));

        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:28,代码来源:AddAddress.xaml.cs

示例5: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            // Initialize the database if necessary
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Create the tables if they don't exist
                db.CreateTable<Day>();
                db.CreateTable<Intake>();
                Day day = new Day();
                day.Date = DateTime.Today;
                db.Insert(day);
            }

            CurrentDay = DayViewModel.GetDayByDate(DateTime.Today);

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
开发者ID:porokuokka,项目名称:CaloriesCounter,代码行数:53,代码来源:App.xaml.cs

示例6: Button_Click_1

        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            baza = TextBoxNazwaNowejBazy.Text;
            string komunikat = textboxkomunikatistniejacabaza.Text;
            string komunikat2 = TextBoxKomunikatNazwaZastrzezona.Text;
            string komunikat3 = TextBoxZaKrotkaNazwa.Text;
            
            if (baza.Equals("AppData") | baza.Equals("eFiszki") | baza.Equals("efiszki"))
                {
                    MessageDialog dialog = new MessageDialog(komunikat2);
                    await dialog.ShowAsync();
                }
            else if (baza.Length < 2)
            {
                MessageDialog dialog = new MessageDialog(komunikat3);
                await dialog.ShowAsync();

            }

            else
            {
                StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
                IReadOnlyList<StorageFile> fList = await folder.GetFilesAsync();
                int sprawdz = 0;
                foreach (var f in fList)
                {
                    if (baza.Equals(f.DisplayName))
                    {
                        sprawdz = 1;
                    }
                };

                if (sprawdz == 1)
                {
                    MessageDialog dialog = new MessageDialog(komunikat);
                    await dialog.ShowAsync();
                }
                else
                {
                    string DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, baza + ".sqlite");
                    using (var db = new SQLite.SQLiteConnection(DBPath))
                    {
                        db.CreateTable<UserDefaultDataBase>();
                    }


                    this.Frame.Navigate(typeof(DodajSlowko));

                }


            }
            
        }
开发者ID:jkisicki,项目名称:eFiszki_Project,代码行数:54,代码来源:DodajBaze.xaml.cs

示例7: loadOldMessages

 private List<OldMessageSettings> loadOldMessages()
 {
     var oldMessages = new List<OldMessageSettings>();
     using (var db = new SQLite.SQLiteConnection(this.DBPath))
     {
         db.CreateTable<OldMessageSettings>();
         foreach (var oldMessage in db.Table<OldMessageSettings>().OrderByDescending(msg => msg.Added))
         {
             oldMessages.Add(oldMessage);
         }
     }
     return oldMessages;
 }
开发者ID:Osceus,项目名称:Countdown,代码行数:13,代码来源:MessageSettingsRepository.cs

示例8: loadFavoriteMessage

 private List<FavoriteMessageSettings> loadFavoriteMessage()
 {
     var favMessages = new List<FavoriteMessageSettings>();
     using (var db = new SQLite.SQLiteConnection(this.DBPath))
     {
         db.CreateTable<FavoriteMessageSettings>();
         foreach (var favMessage in db.Table<FavoriteMessageSettings>().OrderByDescending(msg => msg.Added))
         {
             favMessages.Add(favMessage);
         }
     }
     return favMessages;
 }
开发者ID:Osceus,项目名称:Countdown,代码行数:13,代码来源:MessageSettingsRepository.cs

示例9: BindRequests

        public static Array BindRequests()
        {
            var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            using (var db = new SQLite.SQLiteConnection(dbPath))
            {
                db.CreateTable<Appointment>();

                var appoinmentquery = (from x in db.Table<Appointment>()
                                       where x.OwnerUserID == App.loggedInUser.Id
                                       orderby x.Date
                                       select x).ToArray();

                return appoinmentquery;
            }
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:15,代码来源:GetData.cs

示例10: EmprestimoViewModel

        public EmprestimoViewModel()
        {
            using (var db = new SQLite.SQLiteConnection(DB_PATH))
            {
                db.CreateTable<Model.Emprestimo>();
            }

            ListaDeEmprestimos = GetAllEmprestimos();

            ListaDeEmprestimosAtivos = ListaDeEmprestimos.Where(i => !i.DataDevolucao.HasValue).ToList();

            SalvarEmprestimo = new ViewModel.DelegateCommand<Model.Emprestimo>(Salvar);
            DevolverLivro = new ViewModel.DelegateCommand<Model.Emprestimo>(Devolver);
            VisualizarEmprestimo = new ViewModel.DelegateCommand<Model.Emprestimo>(Visualizar);
        }
开发者ID:yvanafv,项目名称:windowsphoneapp,代码行数:15,代码来源:EmprestimoViewModel.cs

示例11: btnRegister_Click

        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            if (FieldValidationExtensions.GetIsValid(RegisterUserName) && FieldValidationExtensions.GetIsValid(RegisterPassword) && FieldValidationExtensions.GetIsValid(RegisterEmail))
            {
                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable<User>();

                    db.RunInTransaction(() =>
                        {
                            db.Insert(new User() { UserName = RegisterUserName.Text, PassWord = RegisterPassword.Password, EmailAddress = RegisterEmail.Text });
                        });
                }

                this.Frame.Navigate(typeof(MainPage));
            }
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:18,代码来源:Register.xaml.cs

示例12: UsuarioViewModel

        public UsuarioViewModel()
        {
            using (var db = new SQLite.SQLiteConnection(DB_PATH))
            {
                db.CreateTable<Model.Usuario>();
            }

            ListaDeUsuarios = GetAllUsuario().Where(i => String.IsNullOrEmpty(i.Senha)).ToList();

            ListaDeUsuariosComSenha = GetAllUsuario().Where(i => !String.IsNullOrEmpty(i.Senha)).ToList();

            DeleteUsuario = new ViewModel.DelegateCommand<Model.Usuario>(Delete);
            UpdateUsuario = new ViewModel.DelegateCommand<Model.Usuario>(Update);
            EditUsuario = new ViewModel.DelegateCommand<Model.Usuario>(Edit);
            SalvarUsuarioAcesso = new ViewModel.DelegateCommand<Model.Usuario>(Salvar);
            LoginUsuario = new ViewModel.DelegateCommand<Model.Usuario>(Logar);
            SelecionarUsuarioParaEmprestimo = new ViewModel.DelegateCommand<Model.Usuario>(SelecionarParaEmprestimo);
        }
开发者ID:yvanafv,项目名称:windowsphoneapp,代码行数:18,代码来源:UsuarioViewModel.cs

示例13: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            DBPath = Path.Combine(
                Windows.Storage.ApplicationData.Current.LocalFolder.Path, "customers.s3db");
            // Initialize the database if necessary
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Create the tables if they don't exist
                db.CreateTable<Customer>();
            }

            LoadData();

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
开发者ID:noriike,项目名称:xaml-106136,代码行数:50,代码来源:App.xaml.cs

示例14: addMeterBox

            public void addMeterBox(string meterBoxNumber, double current)
            {
                
                string result = string.Empty;
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                    try
                    {
                        db.CreateTable<MeterBox>();
                        int success1 = db.Insert(new MeterBox()
                        {
                            ID = 0,
                            meterBoxNumber = meterBoxNumber,
                            currentUnits = current
                        });
                        var existing = db.Query<MeterBox>("select * from MeterBox").First();
                        if (existing == null)
                        {
                                int success = db.Insert(new MeterBox()
                            {
                                ID = 0,
                                meterBoxNumber = meterBoxNumber,
                                currentUnits = current
                            });
                        }
                        else if(existing != null)
                        {
                            existing.meterBoxNumber = meterBoxNumber;
                            existing.currentUnits = current;
                            db.RunInTransaction(() =>
                            {
                                db.Update(existing);
                            });
                        }
                  
                    }
                    catch (Exception e)
                    {

                    }
                //return "Success";
            }
开发者ID:sovenga,项目名称:ElectricityApp1,代码行数:41,代码来源:MeterViewModel.cs

示例15: BindAddressBook

        public static Array BindAddressBook()
        {
            var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            using (var db = new SQLite.SQLiteConnection(dbPath))
            {
                db.CreateTable<AddressBookEntree>();

                var addressquery = (from x in db.Table<AddressBookEntree>()
                                    where x.OwnerUserID == App.loggedInUser.Id
                                    select x).ToArray();

                var tempquery = addressquery.Select(x => x.EntreeUserID).ToArray();

                var userquery = (from x in db.Table<User>()
                                 where tempquery.Contains(x.Id)
                                 select x).ToArray();


                return userquery;
            }
        }
开发者ID:TimothyJames,项目名称:SIG-Windows8,代码行数:21,代码来源:GetData.cs


注:本文中的SQLite.SQLiteConnection.CreateTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。