Monday, March 9, 2009

Valuable custom LINQ provider tutorials

There are plenty of useful tutorials on writing a custom LINQ Provider, however I find these two very valuable:

1. Old, good LINQ to LDAP by Bart De Smet

2. Surprisingly complete tutorial by Matt Warren where a LINQ-to-SQL-like custom provider is explained very thoroughly.

Do not also miss the LINQ's Dynamic Query helper and the MetaLINQ to discover other interesting variations on LINQ.

3 comments:

Deto said...

interesting.

Recently I was suprised what is the difference between these 2:

1) var items = from n in list select n

2) var items = (from n in list select n).ToArray();

Off course, answer is obvious - first one returns IEnumerable<>, while second returns array .. yes- but there is quite big difference between those two.

Lets get to the point: every foreach statemant used on "items" will act differently on 1 and 2.

If we deal with 2nd example (array), the items object is already created, and foreach doesnt really executes LINQ expression.

If we deal with 1st example, the items is not really a "object" (well, actually it's, but it acts like method that return IEnumerable<> by yielding resuls). ... and that means "items" in first case is just a delegate. Every foreach statemand used on 1st will execute LINQ query.

.. just a funny thing that i discover recently... :)

Deto said...

by the way: check out

http://netpl.blogspot.com/2008/06/c-puzzle-no9-beginner.html

I hope this solution is OK? .. I was very curious about this quizz, it took my few minutes to figure out this forgotten quizz.

Wiktor Zychla said...

yes, the solution to 9th puzzle seems correct.

btw, one of the links I've posted here should help you to find an answer to 13th puzzle.

Regards,
Wiktor