ilookup - filter linq lookup based on values -


i filter linq lookup based on values:

the lookup:

ilookup<int, article> lookup 

here's i've got far isn't working:

ilist<int> cityindexes = getcityindexesbynames(cities);      lookup = lookup                 .where(p => p.any(x => cityindexes.contains((int)x.articlecity)))                 .selectmany(l => l)                 .tolookup(l => (int)l.articleparentindex, l => l); 

just clarify: want articles city index contained in above city index list.

the problem code posted, you're getting articles same id article has matching city index. if unpack groups first, there's no problem.

ilist<int> cityindexes = getcityindexesbynames(cities);  lookup = lookup   .selectmany(g => g)   .where(article => cityindexes.contains((int)article.articlecity)))   .tolookup(article => (int)article.articleparentindex);  

or

lookup = (   g in lookup   article in g   cityindexes.contains((int)article.articlecity)))   select article ).tolookup(article => (int)article.articleparentindex);  

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

java - where to store the user credentials in an enterprise application(EAI)? -

java - netbeans "Please wait - classpath scanning in progress..." -