本文整理汇总了C#中SQLite.SQLiteAsyncConnection类的典型用法代码示例。如果您正苦于以下问题:C# SQLiteAsyncConnection类的具体用法?C# SQLiteAsyncConnection怎么用?C# SQLiteAsyncConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteAsyncConnection类属于SQLite命名空间,在下文中一共展示了SQLiteAsyncConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRecipesAsync
private async Task AddRecipesAsync()
{
var list = await GetAllRecepiesFromHttpRequest();
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbName);
await conn.InsertAllAsync(list);
}
示例2: LoadAlbumViaName
public async Task<AlbumItem> LoadAlbumViaName(int artistId, string albumName)
{
var connection = new SQLiteAsyncConnection(DbPath);
var query = connection.Table<AlbumItem>().Where(x => x.Name.Equals(albumName)).Where(x => x.ArtistId == artistId);
var result = await query.ToListAsync();
return result.FirstOrDefault();
}
示例3: ConnData
private void ConnData()
{
//Creates database if it doesn't exists
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
conn = new SQLite.SQLiteAsyncConnection(dbPath);
}
示例4: CreateDatabase
private static Task CreateDatabase (SQLiteAsyncConnection connection, CancellationToken cancellationToken)
{
return Task.Factory.StartNew(() =>
{
//Create the tables
var createTask = connection.CreateTablesAsync (tableTypes);
createTask.Wait();
//Count number of assignments
var countTask = connection.Table<Assignment>().CountAsync();
countTask.Wait();
//If no assignments exist, insert our initial data
if (countTask.Result == 0)
{
var insertTask = connection.InsertAllAsync(TestData.All);
//Wait for inserts
insertTask.Wait();
//Mark database created
initialized = true;
}
});
}
示例5: acbDrugSearch_TextChanged
/// <summary>
/// For Displaying search result from database
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void acbDrugSearch_TextChanged(object sender, RoutedEventArgs e)
{
var folder = ApplicationData.Current.LocalFolder.GetFolderAsync("DataFolder");
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "DataFile.sqlite"), true);
string pillname = acbDrugSearch.Text;
if (!string.IsNullOrEmpty(pillname) && !string.IsNullOrWhiteSpace(pillname) && pillname.Length > 3)
{
var query = conn.Table<drugs>().Where(x => x.drugname.Contains(pillname));
var result = await query.ToListAsync();
if (result == null)
{
MessageBox.Show("Pill not found.");
}
else
{
List<string> drugnamelist = new List<string>();
foreach (var item in result)
{
dataReadName =item.drugname;
dataReadMilligram = item.strenght;
dataReadNameMilligram = dataReadName + dataReadMilligram;
drugnamelist.Add(dataReadNameMilligram);
}
lstDrugSearch.ItemsSource = drugnamelist;
}
}
}
示例6: Create
private async void Create()
{
Connection = new SQLiteAsyncConnection(dbpath);
// create all tables
Connection.CreateTableAsync<SQLite.Task>();
}
示例7: btnOK_Click
private async void btnOK_Click(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);
Person person = new Person
{
DoctorName = watermarkTextBox.Text,
Date = datepick.ValueString,
Time = timepick.ValueString
};
await conn.InsertAsync(person);
//My_Medi.ViewModels.MainViewModel veiw = new ViewModels.MainViewModel();
//veiw.LoadData();
DataContext = App.ViewModel;
App.ViewModel.Items.Clear();
App.ViewModel.LoadData();
NavigationService.GoBack();
}
示例8: AppBarToggleButton_Checked
private void AppBarToggleButton_Checked(object sender, RoutedEventArgs e)
{
AppBarToggleButton favButton = sender as AppBarToggleButton;
//if ((bool)favButton.IsChecked)
//{
// var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB";
// var con = new SQLiteAsyncConnection(path);
// //await con.InsertAllAsync(results);
// await con.QueryAsync<Result>(string.Format("insert into Result (name,name) values('{0}','{1}')", results[0].name, tblock.Text));
//}
//else
//{
//}
if ((bool)favButton.IsChecked)
{
var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB";
var con = new SQLiteAsyncConnection(path);
con.QueryAsync<Favourite>(string.Format("insert into Favourite (placeName,userName) values('{0}','{1}')", results[0].name, tblock.Text));
}
else if (!(bool)favButton.IsChecked)
{
var path = ApplicationData.Current.LocalFolder.Path + "/myDb1.DB";
var con = new SQLiteAsyncConnection(path);
con.QueryAsync<Favourite>(string.Format("delete from Favourite where placeName = '{0}' and username='{1}'", results[0].name, tblock.Text));
}
}
示例9: DeleteCounterAsync
public async Task DeleteCounterAsync(Counter counter)
{
var connection = new SQLiteAsyncConnection(_dbPath);
await connection.DeleteAsync(counter);
OnCountersChanged();
}
示例10: btnOK_Click
private async void btnOK_Click(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, "people.db"), true);
//string[] per = new string[10];
var per=App.ViewModel.Items[index];
per.LineFive = watermarkTextBox.Text;
per.Linesix = watermarkTextBox1.Text;
per.Lineseven = watermarkTextBox2.Text;
per.Lineeight = watermarkTextBox3.Text;
Person person = new Person()
{
ID=per.Lineone,
DoctorName=per.Linetwo,
Date=per.Linethree,
Time=per.LineFour,
Temperature=per.LineFive,
Bp=per.Linesix,
symptoms=per.Lineseven,
description=per.Lineeight
};
await conn.UpdateAsync(person);
NavigationService.GoBack();
}
示例11: CounterSubscribed
public async static Task<int> CounterSubscribed()
{
SQLiteAsyncConnection sqlConnection = new SQLiteAsyncConnection(DbHelper.DB_PATH);
int counters = await sqlConnection.Table<Counter>().CountAsync();
AppStore.AddValue(Constants.CountersSubscribed, counters.ToString());
return counters;
}
示例12: Button_Click_3
private async void Button_Click_3(object sender, RoutedEventArgs e)
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(ApplicationData.Current.LocalFolder.Path + "\\people.db");
var query = conn.Table<Person>();//.Where(x => x.Name == "张三");
var result = await query.ToListAsync();
listbox.ItemsSource = result;
}
示例13: LoadViaArtistName
async Task<MusicLibraryViewModel.ArtistItem> LoadViaArtistName(string artistName)
{
var connection = new SQLiteAsyncConnection(_dbPath);
var query = connection.Table<MusicLibraryViewModel.ArtistItem>().Where(x => x.Name.Equals(artistName));
var result = await query.ToListAsync();
return result.FirstOrDefault();
}
示例14: GetFirstTrackPathByAlbumId
public async Task<string> GetFirstTrackPathByAlbumId(int albumId)
{
var connection = new SQLiteAsyncConnection(DbPath);
var query = connection.Table<TrackItem>().Where(x => x.AlbumId == albumId);
var result = await query.FirstOrDefaultAsync();
return result != null ? result.Path : null;
}
示例15: OnNavigatedTo
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
bool dbExist = await CheckDbAsync("Tips.db3");
if (!dbExist)
{
await CreateDatabaseAsync();
}
SQLiteAsyncConnection conn = new SQLiteAsyncConnection("Tips.db3");
var query = conn.Table<Tips>();
tips = await query.ToListAsync();
string title1res = tips[tips.Count - 1].title1;
string title2res = tips[tips.Count - 1].title2;
string title3res = tips[tips.Count - 1].title3;
string desc1res = tips[tips.Count - 1].desc1;
string desc2res = tips[tips.Count - 1].desc2;
string desc3res = tips[tips.Count - 1].desc3;
Tips l = new Tips { title1 = title1res, title2 = title2res, title3 = title3res, desc1 = desc1res, desc2 = desc2res, desc3 = desc3res };
t.Add(l);
TipsList.ItemsSource = t;
}