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


C# SQLiteConnection.Table方法代码示例

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


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

示例1: loadButton_Click

        private void loadButton_Click(object sender, EventArgs e)
        {
            SQLiteConnection db = new SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), @"d:\dnd\dndspells.sqlite");
            spells = db.Table<Spell>().ToList<Spell>();

            populateList();
        }
开发者ID:mostak,项目名称:dnd,代码行数:7,代码来源:Form1.cs

示例2: ByteArrays

        public void ByteArrays()
        {
            //Byte Arrays for comparisson
            ByteArrayClass[] byteArrays = new ByteArrayClass[] {
                new ByteArrayClass() { bytes = new byte[] { 1, 2, 3, 4, 250, 252, 253, 254, 255 } }, //Range check
                new ByteArrayClass() { bytes = new byte[] { 0 } }, //null bytes need to be handled correctly
                new ByteArrayClass() { bytes = new byte[] { 0, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 0, 1, 0 } },
                new ByteArrayClass() { bytes = new byte[] { 1, 0, 1 } },
                new ByteArrayClass() { bytes = new byte[] { } }, //Empty byte array should stay empty (and not become null)
                new ByteArrayClass() { bytes = null } //Null should be supported
            };

            SQLiteConnection database = new SQLiteConnection(TestPath.GetTempFileName());
            database.CreateTable<ByteArrayClass>();

            //Insert all of the ByteArrayClass
            foreach (ByteArrayClass b in byteArrays)
                database.Insert(b);

            //Get them back out
            ByteArrayClass[] fetchedByteArrays = database.Table<ByteArrayClass>().OrderBy(x => x.ID).ToArray();

            Assert.AreEqual(fetchedByteArrays.Length, byteArrays.Length);
            //Check they are the same
            for (int i = 0; i < byteArrays.Length; i++)
            {
                byteArrays[i].AssertEquals(fetchedByteArrays[i]);
            }
        }
开发者ID:Banane9,项目名称:sqlite-net,代码行数:30,代码来源:ByteArrayTest.cs

示例3: LoadData

        public static List<ModelDB> LoadData(SaveInfo save = null)
        {
            if (save != null) {
                SetCurrentSave(save);
            }
            var _conn = new SQLiteConnection(Conf.savePath + currentSave.Filename, SQLiteOpenFlags.ReadWrite);
            var loadedData = new List<ModelDB>();
            var subclasses = GameState.GetGeneratedModelTypes();

            foreach(var c in subclasses) {
                var instance = Activator.CreateInstance(c);
                try {
                    _conn.Table(instance).ToList();
                    var query = _conn.GetType().GetMethod("Table", new Type[] { })
                        .MakeGenericMethod(c)
                        .Invoke(_conn, null) as IEnumerable;
                    foreach (var item in query) {
                        loadedData.Add((ModelDB)item);
                    }
                } catch (SQLiteException) {
                    // it's gonna complain about missing tables. ignore them
                }
            }
            return loadedData;
        }
开发者ID:alasdairhurst,项目名称:ELB,代码行数:25,代码来源:SaveManager.cs

示例4: LoadPlaylist

 public List<BackgroundTrackItem> LoadPlaylist()
 {
     using (var c = new SQLiteConnection(platform, DbPath))
     {
         var list = new List<BackgroundTrackItem>(c.Table<BackgroundTrackItem>().ToList());
         return list;
     }
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:8,代码来源:BackgroundTrackDatabase.cs

示例5: GetJobsByJourneyId

 public ReadOnlyCollection<JobDto> GetJobsByJourneyId(int journeyId)
 {
     using (var databaseConnection = new SQLiteConnection(new SQLitePlatformWP8(), this.DatabaseFilePath))
     {
         var jobs = databaseConnection.Table<Job>().Where(j => j.JourneyId == journeyId).ToList<Job>();
         return new ReadOnlyCollection<JobDto>(Mapper.Map<ObservableCollection<JobDto>>(jobs));
     }
 }
开发者ID:gep13,项目名称:WindowsPhoneSample,代码行数:8,代码来源:JobRepository.cs

示例6: cbRegion_SelectionChanged

 private void cbRegion_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbRegion.SelectedIndex == -1) return;
     var conn = new SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), "VKCrawler.db");
     cbCity.ItemsSource = conn.Table<City>()
         .Where(v => v.countryId.Equals(((Country)cbCountry.SelectedItem).id))
         .Where(v => v.regionId.Equals(((Region)cbRegion.SelectedItem).id))
         .OrderBy(v => v.title);
     cbCity.IsEnabled = true;
 }
开发者ID:maxim-b-dev,项目名称:VKCrawler,代码行数:10,代码来源:DataWindow.xaml.cs

示例7: cbCountry_SelectionChanged

 private void cbCountry_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cbCountry.SelectedIndex == -1) return;
     var conn = new SQLiteConnection(new SQLite.Net.Platform.Win32.SQLitePlatformWin32(), "VKCrawler.db");
     cbRegion.ItemsSource = conn.Table<Region>()
         .Where(v => v.countryId.Equals(((Country)cbCountry.SelectedItem).id))
         .Concat(new[] { new Region { id = 0, countryId = ((Country)cbCountry.SelectedItem).id, title = "Города особого значения" } })
         .OrderBy(v => v.title);
     cbRegion.IsEnabled = true;
 }
开发者ID:maxim-b-dev,项目名称:VKCrawler,代码行数:10,代码来源:DataWindow.xaml.cs

示例8: ToModel

 public static ObservableCollection<RemindListDB> ToModel()
 {
     var conn = new SQLiteConnection(new SQLitePlatformWinRT(), App.RemindListDBPath);
     var list = conn.Table<RemindListDB>();
     ObservableCollection<RemindListDB> modelList = new ObservableCollection<RemindListDB>();
     foreach (var item in list)
     {
         modelList.Add(item);
     }
     return modelList;
 }
开发者ID:RedrockMobile,项目名称:CyxbsMobile_Win,代码行数:11,代码来源:DatabaseMethod.cs

示例9: GetAllStudents

        /// <summary>
        /// Retrive all the Students in the Database
        /// </summary>
        /// <returns></returns>
        #region Students
        public static List<Student> GetAllStudents()
        {
            List<Student> list;

            // Create a new connection
            using (var db = new SQLiteConnection(new SQLitePlatformWinRT(), DbPath))
            {
                list = (from p in db.Table<Student>()
                        select p).ToList();
            }

            return list;
        }
开发者ID:DarryStonem,项目名称:SQLiteUWP-Sample,代码行数:18,代码来源:Database.cs

示例10: UpdateJobStatus

        public JobDto UpdateJobStatus(int jobId, string status)
        {
            using (var databaseConnection = new SQLiteConnection(new SQLitePlatformWP8(), this.DatabaseFilePath))
            {
                var job = databaseConnection.Table<Job>().FirstOrDefault(j => j.Id == jobId);

                if (job == null)
                {
                    throw new Exception("Unable to find Job in database!");
                }

                job.JobStatus = status;
                databaseConnection.Update(job);

                return Mapper.Map<JobDto>(job);
            }
        }
开发者ID:gep13,项目名称:WindowsPhoneSample,代码行数:17,代码来源:JobRepository.cs

示例11: CheckCardImages

 /// <summary>
 /// Checks what card images shoud be shown and places them
 /// </summary>
 public void CheckCardImages()
 {
     try
     {
         int card = 0;
         string name;
         using (SQLiteConnection db = new SQLiteConnection(new SQLitePlatformWinRT(), App.path))
         {
             //Number of packs
             int size = MainPage.numberOfPacks;
             //Retrieves all savedcards
             IEnumerable<SavedCards> query = db.Table<SavedCards>().OrderBy(x => x.CardNumber);
             //Used to retrieve all cards in a pack
             IEnumerable<int> packquery;
             for (int pack = 1; pack <= size; pack++)
             {
                 packquery = query.Where(x => x.PackNumber == pack).Select(x => x.Image);
                 for (card = 0; card <= packquery.Count() - 1; card++)// Place correct images to the buttons
                 {
                     Button button = new Button { };
                     name = "SavedCardP" + pack + "C" + card;
                     button = (Button)FindName(name);
                     var brush = new ImageBrush();
                     //Select a image that corresponds with card number
                     int image = packquery.ElementAt(card);
                     brush.ImageSource = new BitmapImage(new Uri(@"ms-appx:///" + FolderPath + "/" + Convert.ToString(image) + ImageEnding));
                     button.Background = brush;
                 }
                 for (int emptyCard = packquery.Count(); emptyCard <= 11; emptyCard++) // Place empty images
                 {
                     Button button = new Button { };
                     name = "SavedCardP" + pack + "C" + emptyCard;
                     button = (Button)FindName(name);
                     var brush = new ImageBrush();
                     brush.ImageSource = new BitmapImage(new Uri(@"ms-appx:///Images/Card2.png"));
                     button.Background = brush;
                 }
             }
         }
     }
     catch (Exception error)
     {
         Debug.WriteLine(error.Message);
     }
 }
开发者ID:Joonas-Virtanen,项目名称:IHaveIdeas,代码行数:48,代码来源:BrowseCards.xaml.cs

示例12: ClearRemindItem

        public static List<string> ClearRemindItem()
        {
            var conn = new SQLiteConnection(new SQLitePlatformWinRT(), App.RemindListDBPath);
            var list = conn.Table<RemindListDB>();
            List<string> TagList = new List<string>();
            foreach (var item in list)
            {
                var itemList = item.Id_system.Split(',');
                for (int i = 0; i < itemList.Count(); i++)
                {
                    TagList.Add(itemList[i]);
                }
            }
            //var TagList = from x in list where x.Id_system.Equals("") select x.Id_system;

            conn.DropTable<RemindListDB>();
            conn.CreateTable<RemindListDB>();
            return TagList;
        }
开发者ID:RedrockMobile,项目名称:CyxbsMobile_Win,代码行数:19,代码来源:DatabaseMethod.cs

示例13: GetItems

        public ObservableCollection<MSPCrew> GetItems()
        {
            _items = new ObservableCollection<MSPCrew>();

            using (var db = new SQLiteConnection(App.SQLITE_PLATFORM,App.DB_PATH))
            {
                var query = db.Table<MSPCrew>().OrderBy(c => c.Name);
                foreach (var msp in query)
                {
                    var _item = new MSPCrew()
                    {
                        Id = msp.Id,
                        Name = msp.Name,
                        Campus = msp.Campus
                    };
                    _items.Add(_item);
                }
            }
            return _items;
        }
开发者ID:nobodykid,项目名称:MSPSparks-Surya,代码行数:20,代码来源:MainPageViewModel.cs

示例14: GetItems

 public ObservableCollection<MediaViewModel> GetItems()
 {
     items = new ObservableCollection<MediaViewModel>();
     using (var db = new SQLiteConnection(App.SQLITE_PLATFORM, App.DB_PATH))
     {
         var query = db.Table<Media>().OrderBy(c => c.Id);
         foreach (var _item in query)
         {
             var item = new MediaViewModel()
             {
                 Id = _item.Id,
                 Name = _item.Name,
                 CreationDate = _item.CreationDate,
                 VidOrPic = _item.VidOrPic
             };
             items.Add(item);
         }
     }
     return items;
 }
开发者ID:Kinani,项目名称:TimelineMe-deprecated-,代码行数:20,代码来源:MediasViewModel.cs

示例15: CreateDbConnection

		public static SQLiteConnection CreateDbConnection()
		{

			if (SQLitePlatform == null || string.IsNullOrWhiteSpace(DatabasePath))
				throw new Exception("Parameters SQLitePlatform and DatabasePath must be set before using this method.");

			_connection = new SQLiteConnection(SQLitePlatform, DatabasePath);

			_connection.CreateTable<Notebook>();
			_connection.CreateTable<Note>();
			if (_connection.Table<Notebook>().ToList().Count == 0)//check if there are 0 notebooks -> add a default one
			{
				_connection.Insert(new Notebook()
				{
					Id = Guid.NewGuid().ToString(),
					Name = "First Notebook",
					CreatedDate = DateTime.Now,
					ModifiedDate = DateTime.Now,
				});
			}
			return _connection;
		}
开发者ID:Ferencz8,项目名称:RepeatApp,代码行数:22,代码来源:Util.cs


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