ADO.NET Entity Model and LINQ

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-03-24T09:43:45Z Indexed on 2010/03/24 10:23 UTC
Read the original article Hit count: 383

Filed under:
|
|
|

Hi all

I'm using an ADO.NET Entity Model which I'm trying to query using LINQ.

The problem I'm having is that I can't specify the where clause as I'd like. For instance, consider the following query:

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
        }
    }
}

Ideally, I'd like that to become:

var accounts = from a in db.Accounts
               where a.Identifiers.Identifier == identifier
               select a;

I'm guessing I've probably not set up my Entity Model correctly in VS2010. Any advice you can offer would be gratefully received.

Thanks,

Richard.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about ADO.NET