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

  • SEARCH
  • Home
  • 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 3275434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:08:38+00:00 2026-05-17T19:08:38+00:00

I use Framework Entity 4 in my project. I would like to create a

  • 0

I use Framework Entity 4 in my project.
I would like to create a function that will return an Expression
Nothing seem to work. I get this Internal .Net Framework Data Provider error 1025.

Here is my Expression Method

   public Expression<Func<SupplierTypeText, bool>> GetLmbLang()
   {
       return (p => p.LangID == 1);
   }

I call the GetLmbLang method and get an error.

var ViewModel = _db.Suppliers.Select(model => new {
                model,
                SupType = model.SupplierType.SupplierTypeTexts.Where(repBase.GetLmbLang().Compile())
            });

            Response.Write("<pre>");
            Response.Write(((ObjectQuery)ViewModel).ToTraceString());
            Response.Write("</pre>");

If I write the expression directly in the WHERE clause , there is no problem.

var ViewModel = _db.Suppliers.Select(model => new {
                model,
                SupType = model.SupplierType.SupplierTypeTexts.Where(p => p.LangID == 1)
            });

Thanks.

  • 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-17T19:08:38+00:00Added an answer on May 17, 2026 at 7:08 pm

    That’s because you invoke Compile Method on your expression and you don’t need to. You should just pass repBase.GetLmbLang() as the predicate to the Where method like this:

    SupType = model.SupplierType.SupplierTypeTexts.Where(repBase.GetLmbLang())
    

    EDIT:

    I think you’ve misunderstood a little about when you should use Expression<Func<SupplierTypeText, bool>> and when only Func<SupplierTypeText, bool>.

    Basically when you invoke Where method on model.SupplierType.SupplierTypeTexts you are calling Enumerable.Where Method with this signature (LINQ to Objects):

    public static IEnumerable<TSource> Where<TSource>(
            this IEnumerable<TSource> source,
            Func<TSource, bool> predicate
    )
    

    But, by providing Expression<Func<SupplierTypeText, bool>> you actually meant Queryable.Where which has this signature (LINQ to Entities):

    public static IQueryable<TSource> Where(
            this IQueryable<TSource> source,
            Expression<Func<TSource, bool>> predicate
    )
    

    Now what happened there is that when you code model.SupplierType.SupplierTypeTexts.Where(repBase.GetLmbLang())
    SupplierTypeTexts is populating from database by lazy loading and become a ready EntityCollection in memory for you to query so your first solution is to change the GetLmbLang() method accordingly:

    public Func<SupplierTypeText, bool> GetLmbLang() {
           return (p => p.LangID == 1);
    }
    

    and then call it like this inside your anonymous class:

    SupType = model.SupplierType.SupplierTypeTexts.Where(repBase.GetLmbLang())
    

    Your second solution would be to keep the GetLmbLang() method as it is now and actually change the way you create SupType:

    var ViewModel = _db.Suppliers.Select(model => new {
                    model,
                    SupType = _db.SupplierTypeTexts
                                 .Where(repBase.GetLmbLang())
                });
    

    A Note on Provider Error 1205:

    This exception happens only when you are doing a projection with anonymous types and passing an Expression<Func<...>> inside like the code below:

    var ViewModel = _db.Suppliers.Select(model => new {
            SupType = _db.SupplierTypeTexts.Where(repBase.GetLmbLang())
    });
    

    If you remove the projection with anonymous type or if you keep the projection and get rid of the method that returns Expression<Func<...>> it will go away. Why this happens? I have no idea, it sounds like a provider bug to me. But one thing for sure is that theoretically it should works and there is absolutely nothing wrong with this code. That being said, feel free to start a new question and see what other guys have to say.

    If you want to do so, then your question title should be something like this:
    Why am I getting Provider Error 1205 exception when I try to do a projection with anonymous type while passing in an Expression<Func<...>>?

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

Sidebar

Related Questions

No related questions found

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.