entity framework - EF LINQ select entities where Id is in List -


i trying select list of entities using ef , linq , should retrieve has specific accountid inside participants icollection

public class conversation {     public conversation()     {         participants = new list<account>();         messages = new list<message>();     }      [key]     public int32 conversationid { get; set; }     public icollection<message> messages { get; set; }     public icollection<account> participants { get; set; } } 

_db dbcontext

public async task<list<conversation>> findbyaccountidasync(int32 id) {    return await _db.conversations.where(....).tolistasync();     // .... select conversations id == accountid inside icollection<account> participants } 

i have no idea on how compose query in linq

use any:

return await _db.conversations     .where(c => c.participants.any(p => p.id == id))     .asqueryable()     .tolistasync(); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -