Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LINQ to Objects Subquery ?
Message
De
04/09/2009 12:17:34
 
 
À
04/09/2009 11:04:25
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
VB 9.0
OS:
Vista
Divers
Thread ID:
01422566
Message ID:
01422690
Vues:
46
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).
>
>
//method syntax - richer
>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


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform