SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Removing "static" from my functions

    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:
    Code Csharp:
    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?

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Ah, I think the issue is that I'm using a separate context due to the use of separate databases. Hmmmmmmm.... This has nothing to do with the use of static. I guess I found some misleading advice.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •