c# - LINQ: Compare List A and B, if in B, select item in A -


i have list of tags (list a), , list of tags matched topics (list b). want parse items in list b , if it's there, have select item in list a. i've tried 2 line , 1 line statement this, run same problem no matter try. here's 1 line attempt of code:

var tags = db.tags.where(x=>x.tagid == db.taglink.where(y => y.topicid == incomingtopicid)).tolist(); 

list , b have common column of tag id.

any suggestions?

update

the structure of db.taglink these columns: taglinkid(key), topicid, tagid.

the structure of db.tags these columns: tagid, tagname, istagscored.

there several ways go it. here's 1 approach:

var tags = db.tags     .where(x=>db.taglink         .any(y => y.tagid == x.tagid && y.topicid == incomingtopicid))     .tolist(); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -