使用 sqlite-net 在 Windows 8 Metro C# 中加入 SQLite [英] SQLite Join in Windows 8 Metro C# with sqlite-net

查看:30
本文介绍了使用 sqlite-net 在 Windows 8 Metro C# 中加入 SQLite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 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");

有人知道怎么做吗?

推荐答案

连接很好,如果过时 - 你应该使用更新的语法

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");

这篇关于使用 sqlite-net 在 Windows 8 Metro C# 中加入 SQLite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆