SQLite通过sqlite-net加入Windows 8 Metro C#

问题描述:

我正在将C#和SQLite用于Windows-8-Metro-App的数据库.我想使用Join-Command,但不知道如何读取给定的返回数据.这将不起作用:

I am using C# and SQLite for a Database for a Windows-8-Metro-App. I want to use a Join-Command, but don't know how to read the given back data. This will not work:

db.Query<Person>("SELECT * FROM Person, Job WHERE Person.JobID = Job.ID");

这还没有实现:

db.Query<Person, Job>("SELECT * FROM Person, Job WHERE Person.JobID = Job.ID");

有人知道如何做到这一点?

Someone has an idea how to do this?

如果过时,则联接很好-您应使用较新的语法

The join is fine, if antiquated - you should use the newer syntax

 SELECT * FROM Person INNER JOIN Job ON Person.JobID = Job.ID

您的问题在于您要返回的内容-您同时返回了Person数据和Job数据-因此您需要创建一个与要返回的数据结构匹配的类-或仅返回一个人或一个工作.

Your problem is in what you are returning - you are returning both Person data and Job data - so you need to create a class that matches the data structure that you are returning - or return just a person, or a job.

 db.Query<Person>("SELECT Person.* FROM Person INNER JOIN Job ON Person.JobID = Job.ID");           
 db.Query<Job>("SELECT Job.* FROM Person INNER JOIN Job ON Person.JobID = Job.ID");