【发布时间】:2023-04-03 18:55:01
【问题描述】:
我正在 Xamarin.Forms 跨平台开发这个宠物项目。我在使用约束在 SQLite 中运行查询时遇到困难。我能够列出存储在表格中的所有元素。但是,我无法在表中查询具有相同 AccountNumber 的所有作业。我到处搜索,但找不到答案。任何人都可以提供一种可以帮助的工作方法,并在此先感谢您。
public SearchPage()
{
InitializeComponent();
_connection = DependencyService.Get<ISQLiteDb> ().GetConnection();
}
private SQLiteAsyncConnection _connection;
private ObservableCollection<Job> _jobs;
public class NewJobTable
{
[PrimaryKey]
public string JobID { get; set; }
public long AccountNumber { get; set; }
public int JobNumber { get; set; }
public DateTime DateCompleted { get; set; }
}
protected override async void OnAppearing()
{
await _connection.CreateTableAsync<Job>();
var jobs = await _connection.Table<Job>().ToListAsync();
_jobs = new ObservableCollection<Job>(jobs);
JobListView.ItemsSource = _jobs;
base.OnAppearing();
}
【问题讨论】:
标签: c# sqlite xamarin.forms cross-platform