jackjohnson44
asked on
linq to objects trying to find object based on list of ids
I have
Class Spread
List<string>ContractIds
I am trying to find all spreads in a list where the spread contains a contractId from another list. I can't figure it out.
Here is what I have tried:
public List<Spread> GetSpreadByContractIds(Lis t<string> contractIds)
{
//var spreads = (from s in Spreads where contractIds.Contains(s => s.ContractIds) select s).ToList();
List<Spread> results = (from s in Spreads join cts in contractIds on s.ContractIds equals cts select s).ToList();
return results;
}
Class Spread
List<string>ContractIds
I am trying to find all spreads in a list where the spread contains a contractId from another list. I can't figure it out.
Here is what I have tried:
public List<Spread> GetSpreadByContractIds(Lis
{
//var spreads = (from s in Spreads where contractIds.Contains(s => s.ContractIds) select s).ToList();
List<Spread> results = (from s in Spreads join cts in contractIds on s.ContractIds equals cts select s).ToList();
return results;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.