[英]ADO.NET Entity Model and LINQ
我正在尝试使用LINQ查询的ADO.NET实体模型。
我遇到的问题是我无法根据需要指定where子句。 例如,考虑以下查询:
AccountsDM db = new AccountsDM(ConfigurationManager.ConnectionStrings["PrimaryEF"].ConnectionString);
var accounts = from a in db.Accounts
select a;
foreach (var account in accounts)
{
foreach (var ident in account.Identifiers)
{
if (ident.Identifier == identifier)
{
// ident.Identifier is what I'd like to be filtering in the WHERE clause below
}
}
}
理想情况下,我希望成为:
var accounts = from a in db.Accounts
where a.Identifiers.Identifier == identifier
select a;
我猜想我可能没有在VS2010中正确设置我的实体模型。 您能提供的任何建议将不胜感激。
谢谢,
理查德。
LINQ to Objects支持如下查询。 尝试在LINQ to Entities =)中进行
var accounts = from a in db.Accounts
from i in a.Identifiers
where i.Identifier == identifier
select a;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.