Well I wouldn't quite agree that performance hit can be pretty bad. Even if it were true now, it won't be soon.
Cetin
>Cetin, sagol and Viv, Thanks
>
>This definitely gets me going in the right direction. I think I am starting to "get" what LINQ has to offer. I know the performance hit can be pretty bad in some circumstances, especially in Linq to SQL but for doing this kind of stuff with small collections this is a beautiful thing.
>
>Just ordered a couple of LINQ books and will use your examples to make use of LINQ for the first time in one of my apps. This is definitely useful stuff!
>
>
>
>>>I am the newest of Linq newbies so feel free to speak slowly and use small words <bg>
>>>
>>>I have list of integers.
>>>
>>>I have a business object of strongly type properties.
>>>( the bo implements ienumerable through one of its own functions but if I can't get that to work I can convert the data to an array or some other object that implement the interface in a standard way. The bos also expose all standard ado properties re datatable, currentview etc if that helps)
>
>>>
>>>There are properties
>>>
>>>ikey,description, itemplateskey
>>>
>>>I want to select the bo.ikey where itemplateskey is not in the list of integers.
>>>
>>>(corallaries would includes selecting all records from one bo where some value in that bo is found or not found in some field in another bo )
>>>
>>>I think I've stripped down the problem to the essentials. Any help on linq subquery syntax with be appreciated as I think that is probably going to be the most elegant solution for a lot of this kind of stuff
>>>
>>>TIA
>>
>>Viv already covered it really. I am only doing a second pass with small letters:)
>>
>>IEnumerable, IQueryable,List,Array ... IOW anything that you can enumerate locally or remotely should remind you Linq:) So you don't need to get an array (Linq do that for you if you want with .ToArray() extension method).
>>
>>
>>var query = boCollection.Where( bo => !intList.Contains( bo.itemplateskey ) ).Select( bo => bo.ikey );
>>
>>// or - comprehension syntax
>>
>>var query = from bo in boCollection
>> where !intList.Contains( bo.itemplateskey )
>> select bo.ikey;
>>
>>Cetin