Thursday, March 26, 2009

Linq Example for Group Join

Hi All,

I have just started bringing LINQs to my work, and learning some new things. So I thought I will store it here before I forget it ;)

I had a simple problem, where in I had to loop through a list of files and to get out few Extensions. For example, If I have a list of around 500 files in the drive, I need to get the files with some valid extension, for eg, Images. So for that, I created a files list with the name of fileList and created an array with the valid extensions. I named that array by IMAGES.

Now to get the list of files with valid extensions I used the following code:


Dim result = From s In fileList Group Join p In IMAGES On s.Extension.ToUpper() Equals p.ToUpper() _ Into Group From p In Group Select s

1 comment:

Anonymous said...

It is extremely interesting for me to read that blog. Thanks for it. I like such topics and everything that is connected to them. I definitely want to read more soon.