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


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

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


在下文中一共展示了SQLite.SQLiteConnection.Insert方法的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: Insert

 public void Insert(Locale model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:LocaleService.cs

示例3: AddAlbum

        public bool AddAlbum(AlbumViewModel model)
        {
            try
            {
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                {
                    int success = db.Insert(new Album()
                    {
                        CollectionId = model.CollectionId,
                        Title = model.Title,
                        Artist = model.Artist,
                        LastFmId = model.LastFmId,
                        MusicBrainzId = model.MusicBrainzId,
                        DateAdded = DateTime.Now,
                        Void = false
                    });
                    if (success != 0)
                        return true;
                }
                return false;
            }

            catch
            {
                return false;
            }
        }
开发者ID:Narelle,项目名称:MusicCollection,代码行数:27,代码来源:AlbumViewModel.cs

示例4: AddPet

        public int AddPet(Pet _pet)
        {
            //returns new ID
            int success;
            using (var db = new SQLite.SQLiteConnection(Constants.DbPath))
            {
                success = db.Insert(new Pet()
                {
                    PetStageId = _pet.PetStageId,
                    FavoriteGameObjectId = _pet.FavoriteGameObjectId,
                    DislikeGameObjectId = _pet.DislikeGameObjectId,
                    Name = _pet.Name,
                    Health = _pet.Health,
                    Hygene = _pet.Hygene,
                    Hunger = _pet.Hunger,
                    Energy = _pet.Energy,
                    Discipline = _pet.Discipline,
                    Mood = _pet.Mood,
                    Gender = _pet.Gender,
                    Age = _pet.Age,
                    Sleeping = _pet.Sleeping,
                    Current = _pet.Current,
                    BirthDate = _pet.BirthDate,
                    LastUpdated = _pet.LastUpdated,
                    Dead = false
                });

            }
            return success;
        }
开发者ID:janisskuja,项目名称:tamagotchi,代码行数:30,代码来源:PetRepository.cs

示例5: Insert

 private void Insert(Source model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:SourceService.cs

示例6: butSaveClick

 private void butSaveClick(object sender,EventArgs e)
 {
     TextView txtprinter =FindViewById<TextView> (Resource.Id.txtad_printer);
     TextView txtprefix =FindViewById<TextView> (Resource.Id.txtad_prefix);
     TextView txttitle =FindViewById<TextView> (Resource.Id.txtad_title);
     pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
     AdPara apra = new AdPara ();
     apra.Prefix = txtprefix.Text.ToUpper();
     apra.PrinterName = txtprinter.Text.ToUpper();
     using (var db = new SQLite.SQLiteConnection(pathToDatabase))
     {
         var list  = db.Table<AdPara> ().ToList<AdPara> ();
         if (list.Count == 0) {
             db.Insert (apra);
         } else {
             apra = list [0];
             apra.Prefix = txtprefix.Text.ToUpper();
             apra.PrinterName = txtprinter.Text.ToUpper();
             apra.PaperSize = spinner.SelectedItem.ToString ();
             apra.ReceiptTitle =txttitle.Text.ToUpper();
             db.Update (apra);
         }
     }
     base.OnBackPressed();
 }
开发者ID:mokth,项目名称:merpV2Production,代码行数:25,代码来源:SettingActivity.cs

示例7: 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

示例8: InsertUserLikes

 public void InsertUserLikes(string recipeName, string memberName)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new Likes()
         {
             likesId = 0,
             memName = memberName,
             recipeName = recipeName
         });
     }
 }
开发者ID:butiBisho,项目名称:RecipeGeneratorApp,代码行数:12,代码来源:Insert.cs

示例9: addInstitution

        public void addInstitution(string name)
        {
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                var insert = db.Insert(new Institution()
                {
                    Id = 0,
                    insitution = name
                });

            }
        }
开发者ID:RefMashao,项目名称:InformationalApp,代码行数:12,代码来源:InstitutionViewModel.cs

示例10: setLogIn

       private void setLogIn(string pword, string userName,string id)
       {

           using (var db = new SQLite.SQLiteConnection(app.dbPath))
           {
               int success = db.Insert(new tblLogIn()
               {
                  ID = id,
                  Username = userName,
                  Password = pword,
               });
           }

       }
开发者ID:211136928,项目名称:EMS_Mobile_App,代码行数:14,代码来源:Method.cs

示例11: memberDetails

 public void memberDetails(string _name, string _surname, string _email, string _password)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new Member()
         {
             memId = 0,
             name = _name,
             surname = _surname,
             email = _email,
             password = _password
         });
     }
 }
开发者ID:butiBisho,项目名称:RecipeGeneratorApp,代码行数:14,代码来源:Insert.cs

示例12: savePowerballGeneratedNumbers

 public void savePowerballGeneratedNumbers(int first, int second, int third, int fourth, int fifth)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new PowerBallSaved()
         {
             Id = 0,
             num1 = first,
             num2 = second,
             num3 = third,
             num4 = fourth,
             num5 = fifth
         });
     }
 }
开发者ID:butiBisho,项目名称:LottoAppProjectV2,代码行数:15,代码来源:Lotto.cs

示例13: InsertPerson

		public void InsertPerson()
		{
			if (!databaseCreated) 
			{
				if(File.Exists(GetDatabasePath ()))
					File.Delete (GetDatabasePath ());
				CreateTable ();
				databaseCreated = true;
			}

			var person = new Person { FirstName = "John", LastName = "Doe", TimeStamp = DateTime.Now.Ticks.ToString()};
			using (var db = new SQLite.SQLiteConnection(GetDatabasePath() ))
			{
				db.Insert(person);
			}
		}
开发者ID:Tryan18,项目名称:XAMARIN,代码行数:16,代码来源:ManagePersons.cs

示例14: setUserSavedNumbers

 public void setUserSavedNumbers(int a, int b, int c, int d, int e, int f)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new LottoSaved()
         {
             Id = 0,
             num1 = a,
             num2 = b,
             num3 = c,
             num4 = d,
             num5 = e,
             num6 = f
         });
     }
 }
开发者ID:butiBisho,项目名称:LottoAppProjectV2,代码行数:16,代码来源:Lotto.cs

示例15: 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


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