Solved

What's the LINQ to ensure two lists match?

Posted on 2012-03-13
4
440 Views
Last Modified: 2012-03-13
have a list of string value, which ar Id's

List<string> myListOfIds

I also have an object with an Id, is a list

List<MyObject> myObjectsList

I need to extract a list of all MyObject objects with Id's found in myListOfIds

Thanks.
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 37716209
Use the contains function of the list.  Something like:
myObjectsList.Where (mol ->  myListOfIds.Contains(mol.Id) )
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37716282
Depends on what you mean by "match". Two lists will only match, by default, if their corresponding references match. If you need to check on a particular property, then you might need to involve some lamdas at some point.

Can you clarify your matching criteria?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37716292
Never mind. I didn't read the question properly  : \

I think ged325 has you sorted out  = )
0
 

Author Closing Comment

by:newbieweb
ID: 37717782
Thanks!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET data base connection 35 82
Sending HTML Formatted Email from ASP.NET 2 50
Help with Report Viewer in VS2013 6 26
What is needed to become a DBA? 7 46
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question