Where() method and many to many relationship with the entity framework -
i have 2 tables in database video , tags. video table has 3 fields : name, id , list of tags. tags table has 2 fields : tagname, tagid.
videoviewmodel model = new videoviewmodel { videos = repository.getvideos .where(v => v.name.contains("apple")) };
now let's i've multiple videos there apple in name 1 of these has green it's tags.tagname how can proceed ?
suppose have videos
defined in dbcontext
db
, try this
var result = db.videos.where(x => x.name.equals("apple")) .where(x => x.tags.count(y => y.tagname.equals("green")) == 1);
Comments
Post a Comment