by Tom Hundley
20. May 2010 11:58
Let’s start by saying the code in this example is a really silly, but it’s a great reference for the matter at hand. Let’s assume you need to do a join on multiple columns and you’ve double checked and triple checked that the types are all the same, but you’re stuck with the following error: The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'. The problem is related to anonymous types. The type initializer cannot infer the same anonymous type because the names are not the same. The solution is simple: specify the name in one of the expressions such that they are the same and the problem is solved.
Problem Code:

Solution:

Now that the types AND the *names* are the same, the anonymous type initializer can create the same anonymous type and properly facilitate the join.
Happy coding,
Tom Hundley
Elegant Software Solutions, LLC
Reference:
Thanks to Matt Warren from Microsoft:
http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/bf98ec7a-cb80-4901-8eb2-3aa6636a4fde
by Tom Hundley
20. May 2010 11:37
If you are using “using” statements to manage your data contexts in Linq to SQL (I’m not sure if this applies to Linq to Entity but I imagine it does") and you get the following error: “type used in a using statement must be implicitly convertible to 'System.IDisposable'”, simply add a reference to the “System.Data.Linq” assembly and it solves the problem.
Happy coding,
Tom Hundley
Elegant Software Solutions, LLC
by Tom Hundley
20. May 2010 08:15
I just learned something interesting about HTTP Redirects in IIS 7. I’ve not yet read a lot of details about the inner workings of IIS 7, but I was surprised by this new discovery. Long story short, HTTP Redirects are not applied purely at the site level, but are also tied to the physical path.
I have two websites, each one a separate site in IIS, that both point to the same physical folder (they are both DotNetNuke sites and they use the same DNN installation). I added an HTTP Redirect to one of the sites (I wanted to point my personal DNN site to my new BlogEngine.Net site). I didn’t think to check that the other site was unaffected until someone told me that it was also pointed to my blog. What the hell? It turns out that site that is pointed to the same physical folder will share the HTTP Redirect settings. This is of course a very easy fix, but I am a little surprised by this behavior.
Happy coding,
Tom Hundley
Elegant Software Solutions, LLC