本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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());
}
}
示例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)
{
}
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例9: CreateTable
private void CreateTable()
{
using (var conn = new SQLite.SQLiteConnection(GetDatabasePath()))
{
conn.CreateTable<Person>();
}
}
示例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;
}
示例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;
}
示例12: Get
public Project Get(int projectId)
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
return db.Find<Project>(projectId);
}
}
示例13: FindAll
public IEnumerable<Preference> FindAll()
{
using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
{
return db.Query<Preference>("select * from Preference");
}
}
示例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));
}
示例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
{
}
}