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 8374847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:01:10+00:00 2026-06-09T15:01:10+00:00

I’m trying to use a very simple pre-compiled query within an extension method to

  • 0

I’m trying to use a very simple pre-compiled query within an extension method to retrieve data using LINQ to SQL. SytelineRepository is my custom DataContext that uses external mapping files, and I’m querying the JobOrders table. I’ve been using the custom DataContext for a long time without issue and executing the same query with no problem; I’m just trying to improve performance. However when I try to use CompiledQuery.Compile I get the ArgumentException below.

Here’s the code:

public static class Queries
{
    public static readonly Func<SytelineRepository, String, IQueryable<JobOrder>> GetOpenJobOrdersForItemQuery =
        CompiledQuery.Compile(
        (SytelineRepository r, String itemNumber) => 
            from job in r.JobOrders
            where job.ItemNumber == itemNumber
            select job
        );

    public static IQueryable<JobOrder> GetOpenJobOrdersForItem(this SytelineRepository r, System.String itemNumber)
    {
        return GetOpenJobOrdersForItemQuery(r, itemNumber);
    }

}

As a contrast, this works:

    public static IEnumerable<JobOrder> GetOpenJobOrdersForItem(this SytelineRepository r, System.String itemNumber)
    {
        return GetOpenJobOrdersForItemUncompiledQuery(r, itemNumber);
    }

    public static IQueryable<JobOrder> GetOpenJobOrdersForItemUncompiledQuery(SytelineRepository r, String itemNumber)
    {
        return
            from job in r.JobOrders
            where job.ItemNumber == itemNumber
            select job;
    }

Here’s the full error:

System.ArgumentException was unhandled

Message=Property ‘System.String ItemNumber’ is not defined for type ‘System.Linq.IQueryable`1[Mpicorp.SytelineDataModel.JobOrder]’

   at System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.AccessMember(SqlMember m, SqlExpression expo)
   at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.VisitExpression(SqlExpression expr)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.VisitBinaryOperator(SqlBinary bo)
   at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.VisitExpression(SqlExpression expr)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.VisitSelect(SqlSelect select)
   at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
   at System.Data.Linq.SqlClient.SqlBinder.Visitor.VisitIncludeScope(SqlIncludeScope scope)
   at System.Data.Linq.SqlClient.SqlVisitor.Visit(SqlNode node)
   at System.Data.Linq.SqlClient.SqlBinder.Bind(SqlNode node)
   at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(ResultShape resultShape, Type resultType, SqlNode node, ReadOnlyCollection`1 parentParameters, SqlNodeAnnotations annotations)
   at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Compile(Expression query)
   at System.Data.Linq.CompiledQuery.ExecuteQuery(DataContext context, Object[] args)
   at System.Data.Linq.CompiledQuery.Invoke[TArg0,TArg1,TResult](TArg0 arg0, TArg1 arg1)
   at Mpicorp.SytelineDataModel.Queries.GetOpenJobOrdersForItem(SytelineRepository r, String itemNumber) in C:\SVN\Mpicorp.SytelineDataModel\trunk\SytelineDataModel\Queries.cs:line 21
   at Mpicorp.SytelineDataModel.SytelineRepository.GetTimePhasedInventory(String itemNumber, Boolean includeForecast) in C:\SVN\Mpicorp.SytelineDataModel\trunk\SytelineDataModel\SytelineRepository.cs:line 242
   at RepriceWorkbench.TimePhasedInventoryForm..ctor(SytelineRepository repository, String itemNumber) in C:\SVN\spirepriceutility\trunk\src\POWorkbench\TimePhasedInventoryForm.cs:line 32
   at RepriceWorkbench.TimePhasedMenuForm.goBtn_Click(Object sender, EventArgs e) in C:\SVN\spirepriceutility\trunk\src\POWorkbench\TimePhasedMenuForm.cs:line 25
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at RepriceWorkbench.Program.Main() in C:\SVN\spirepriceutility\trunk\src\POWorkbench\Program.cs:line 66
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
  • 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-06-09T15:01:12+00:00Added an answer on June 9, 2026 at 3:01 pm

    The comment from usr led me to review the definition underlying the code I posted, and that’s where I stumbled across the long-forgotten fact that my table stores several different objects and I was differentiating between them using the repository’s accessors, like this:

        public IQueryable<JobOrder> JobOrders
        {
            get { return GetTable<JobOrder>().Where(j => j.JobType == 'J'); }
        }
    

    Changing the method to use GetTable<>(), as in the following fixed the issue.

        public static readonly Func<SytelineRepository, String, IEnumerable<JobOrder>> GetOpenJobOrdersForItemQuery =
            CompiledQuery.Compile(
            (SytelineRepository r, String itemNumber) =>
                from job in r.GetTable<JobOrder>()
                where job.ItemNumber == itemNumber && job.JobType == 'J' && (job.Status == "F" || job.Status == "R")
                select job
            );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.