Thursday 19 May 2011

Getting a Collection from a collection

This is a quick note on how to search collection from the contents of a collection or in this case a Repository. This uses C# lamdba and .NET 4.0 but will work with .NET3+



public static List GetCustomers ( List customernumbers)
{

var custs = RepositoryCustomers.Find(x=> customernumbers.Contains(x.CustomerNo));

return custs.ToList();
}



Seems really easy once you know how.

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.