Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433572
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:35:33+00:00 2026-05-18T07:35:33+00:00

I have a query that I’d like to pre-compile, however the query is being

  • 0

I have a query that I’d like to pre-compile, however the query is being performed on an already existing ObjectQuery as follows:-

ObjectQuery<Books> books = _ctx.Books.Include("Authors");

books = books.Where(book=>book.Vendor.Listing.Select(vend=>vend.Price > 200));

I would like to use a compiled query for the second query, however that would entail passing the “books” object in to the Compiled Query’s “Invoke” method which when I attempt to do throws an error saying that “Only scalar types are supported” since “books” is of type ObjectQuery.

So I can’t really do something like this:-

var results = QueryCache.GetVendorFilter.Invoke(context,books);

where, GetVendorFilter is a compiled query.

Is there any other way to have this query be compiled ? Does anyone know if EF4 has this limitation ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:35:34+00:00Added an answer on May 18, 2026 at 7:35 am

    My understanding is that a compiled query basically pre-builds the SQL statement for your query expression, but leaves the parameter values undefined. Since SQL doesn’t support using another query as a parameter, it makes sense to me that you can’t do this.

    One thing to be aware of with precompiled queries is that the moment you do anything to them, they become “just another query,” which has to be recompiled when you evaluate it. So even if you just put a call to .Take(10) at the end, you’ve lost the value of the precompiled query.

    Since your books query is pretty much fixed, it should be easy to create a separate precompiled query for this particular scenario, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
I have query like that: (as You see I'd like to retrieve 50% of
I have a query like below that has groups (COL1) and that group's values
I have a query that sums and aggregates alot of data something like this:
Have a query that is failing because the scope is running a query like
I have this query that returns the correct data, but I would like to
I have a query that's something like the following find( { a : {
I have query that goes like that : SELECT DISTINCT S.date1 AS date1, S.date2
I have this query that works as desired, but it seems like there should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.