linq on objects...
want to find if the object exist in its collection
if I have a loop searching in the collection
foreach (myClass r in collections)
{
if (r.field01 == type && r.field02 == id)
return true;
}
return false;
versus
Linq
List <myClassqq =
(from r in SecondaryIds
where r.field01 == type && t.field02 == id
select t).ToList();
1. any performance issues. (lets say there are many obj in collection)
2. how do get collection count from linq or can I set a true variable if
found?
thanks
want to find if the object exist in its collection
if I have a loop searching in the collection
foreach (myClass r in collections)
{
if (r.field01 == type && r.field02 == id)
return true;
}
return false;
versus
Linq
List <myClassqq =
(from r in SecondaryIds
where r.field01 == type && t.field02 == id
select t).ToList();
1. any performance issues. (lets say there are many obj in collection)
2. how do get collection count from linq or can I set a true variable if
found?
thanks
Comment