I have been using compiled queries for just about everything. It seems that in .NET 4 using the static Func<> causes a "Query was compiled for a different mapping source than the one associated with the specified DataContext." exception. I guess it should have done so all along but the exception was ignored in the past. I'm really out of shape in the C# and .NET field so I need a bit of help.
Here is one of my compiled queries:
private static Func<bibleDataContext, string, IQueryable<Bible>>
_theVersion = CompiledQuery.Compile((bibleDataContext context, string bibleVersion) =>
(from v in context.biblesInfos
where v.bibleName == bibleVersion
select new Bible
version = v.versionID,
language = v.languageID,
copyright = v.copyright
public static IQueryable<Bible> theVersion(string bibleVersion)
return _theVersion(context, bibleVersion);
I'd like to take the "static" out of the private function but leave it in the public IQueryable because I use it in a static string extension. I just can't remember what's to be done. Any tips for me?