c# - Filtering a query in Entity Framework based upon a child value -
i've got model set in entity framework (ef) there 2 tables, parent , child, in 1 many relationship. having trouble writing query linq trying retrieve single instance of parent while filtering upon field in parent , field in child. listed below:
var query = c in context.parenttable c.isactive == true && c.childtable.name = "abc" select c;
unfortunately when try fails because no field named "name" appears available via intellisense when type c.childtable.
any guidance appreciated.
that correct because c.childtable not of child type entitycollection<child>. in order make query work, need modify this:
var query = p in context.parenttable c in p.childtable p.isactive == true && c.name == "abc" select p;
Comments
Post a Comment