LINQ2SQL query with IEnumerable as parameter
I would be grateful if someone could help me. I have 2 tables:
Accounts
PK int AccountID
nvarchar(50) Name
and
Captions
PK int CaptionID
FK int AccountID
nvarchar(50) Key
nvarchar(50) Value
Within my code I have DTO:
public class CaptionDto
{
public string Key {get;set;}
public string Value {get;set;}
}
I have to implement method
public IEnumerable<Account> GetAccountsByCaptions(IEnumerable<CaptionDto>
captions);
Basically, I have to check all accounts who have captions (key and value)
matched with all input captions. I am using .NET, C# and this query should
be written using LINQ2SQL. Note that dbContext.Account has property
Captions (FK constraint)
public IEnumerable<Account> GetAccountsByCaptions(IEnumerable<CaptionDto>
captions)
{
using(var dbContext = new AccountDataContext)
{
....
}
}
Thanks in advance.
No comments:
Post a Comment