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


C# SQLite.SQLiteConnection类代码示例

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


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

示例1: FinishedLaunching

		//
		// This method is invoked when the application has loaded and is ready to run. In this
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();
			Xamarin.FormsMaps.Init ();

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "EvolveSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var conn = new SQLite.SQLiteConnection(path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

			// If you have defined a view, add it here:
			// window.RootViewController  = navigationController;
			window.RootViewController = App.GetMainPage ().CreateViewController ();

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
开发者ID:jauggy,项目名称:xamarin-forms-samples,代码行数:40,代码来源:AppDelegate.cs

示例2: FindAllExcept

 public IEnumerable<Project> FindAllExcept(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Project>("select * from Project where Id <> ?", projectId);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:ProjectService.cs

示例3: FinishedLaunching

		//
		// This method is invoked when the application has loaded and is ready to run. In this
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();
			Xamarin.FormsMaps.Init ();

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "EvolveSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var conn = new SQLite.SQLiteConnection(path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

			LoadApplication (new App ());

			return base.FinishedLaunching (app, options);
		}
开发者ID:ZaK14120,项目名称:xamarin-forms-samples,代码行数:35,代码来源:AppDelegate.cs

示例4: Page

		public IPage<Artist> Page(ICriteria<Artist> criteria) {
			using (var cn = new SQLite.SQLiteConnection(_dbConnectionString)) {
				var query = cn.Table<Artist>().AsQueryable();

				if (criteria.Keywords.Any()) {
					criteria.Keywords.ToList().ForEach(word => query = query.Where(a => a.Name.ToLower().Contains(word.ToLower())));
				}

				var totalRecords = query.Count();

				if (criteria.SortBy.Any()) {
					foreach (var kvp in criteria.SortBy) {
						switch (kvp.Value) {
							case ListSortDirection.Ascending:
								query = query.OrderBy(kvp.Key);
								break;
							case ListSortDirection.Descending:
								query = query.OrderBy(kvp.Key + " descending");
								break;
						}
					}
				}

				if (criteria.Page.HasValue) {
					query = query.Skip((criteria.Page.Value - 1) * criteria.PageSize.GetValueOrDefault());
				}

				if (criteria.PageSize.HasValue) {
					query = query.Take(criteria.PageSize.Value);
				}

				return new Page<Artist>(criteria.Page ?? 0, criteria.PageSize ?? totalRecords, totalRecords, query.ToList());
			}
		}
开发者ID:dealproc,项目名称:HalWithNancy,代码行数:34,代码来源:ArtistRepository.cs

示例5: update

        public void update(string name,string address)
        {          
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                try
                {//db.Execute("update meterbox set currentUnits = currentUnits -" + used);
                    var existing = db.Query<Job>("select * from Job").First();

                    if (existing != null)
                    {
                        existing.name = name;
                        existing.address = address;
                        db.RunInTransaction(() =>
                        {
                            db.Update(existing);
                        });
                    }
                }

                catch (Exception e)
                {

                }
            }
        }
开发者ID:Ranzu,项目名称:Voluteers-App,代码行数:25,代码来源:JobViewModel.cs

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

示例7: FindAll

 public IEnumerable<Item> FindAll(int sourceId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Item>("select * from Item where SourceId = ?", sourceId);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:ItemService.cs

示例8: UpdateText

 public void UpdateText(string newText, int id)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Execute("update Item set Text = ? where Id = ?", newText, id);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:ItemService.cs

示例9: CreateTable

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

示例10: GetSingleCollection

        public SingleCollectionViewModel GetSingleCollection(int collectionId)
        {
            SingleCollectionViewModel collection = new SingleCollectionViewModel();

            using (var db = new SQLite.SQLiteConnection(app.DBPath))
            {
                var _collection = (db.Table<Collection>().Where(
                    c => c.Id == collectionId)).FirstOrDefault();
                collection.Id = _collection.Id;
                collection.Title = _collection.Title;
                collection.DateCreated = _collection.DateCreated;
                collection.Void = _collection.Void;

                // GET ALBUMS
                var _albums = (db.Table<Album>().Where(
                    c => c.CollectionId == collectionId)).ToList();

                List<lfm> albumList = new List<lfm>();
                foreach (var _album in _albums)
                {
                    lfm album = LastGetAlbum(_album.MusicBrainzId);
                    albumList.Add(album);
                }
                collection.Albums = albumList;
            }
            return collection;
        }
开发者ID:Narelle,项目名称:MusicCollection,代码行数:27,代码来源:SingleCollectionViewModel.cs

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

示例12: Get

 public Project Get(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Find<Project>(projectId);
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:ProjectService.cs

示例13: FindAll

 public IEnumerable<Preference> FindAll()
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Preference>("select * from Preference");
     }
 }
开发者ID:ktei,项目名称:JsonResxEditor,代码行数:7,代码来源:PreferenceService.cs

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

示例15: RemptionLoaded

        private void RemptionLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Shopping.db3");

                using (var db = new SQLite.SQLiteConnection(path))
                {
                    var a = from x in db.Table<ShopLists>() where x.AdminName == AdminName && x.Condition == 1 select x;
                    //MessageBox.Show(a.Count().ToString());

                    foreach (var v in a)
                    {
                        RedemptionShopList.Add(v);
                    }

                }

                RedemptionList.ItemsSource = RedemptionShopList;
            }
            catch
            {

            }
        }
开发者ID:prabaprakash,项目名称:Visual-Studio-2013,代码行数:25,代码来源:Report.xaml.cs


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