使用 linq 从 SQL Server 数据库中选择两个对象
我有以下 Log
表,
int LogID
text Name
datetime CreationTime
text Content
int CreatorID
我尝试获取由具体 Creator
创建的所有日志
Creator creator = myDataContext.Creator.Single<Creator>(cr => cr.Name == name);
var query = (from l in myDataContext.Log
where l.CreatorID == creator.CreatorID
select l).ToList<Log>();
,但在返回的列表中 Creator
为空。
如何获取给定 Creator
的日志列表?
I've got the following Log
table
int LogID
text Name
datetime CreationTime
text Content
int CreatorID
I try to get all the logs created by a concrete Creator
Creator creator = myDataContext.Creator.Single<Creator>(cr => cr.Name == name);
var query = (from l in myDataContext.Log
where l.CreatorID == creator.CreatorID
select l).ToList<Log>();
but in the returned list the Creator
is null.
How can I get a list of logs for a given Creator
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要设置 LoadOptions:
You need to set LoadOptions: