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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:54:01+00:00 2026-05-19T13:54:01+00:00

I am trying to do a left join using Linq, and failing. I have

  • 0

I am trying to do a left join using Linq, and failing. I have tried to follow a few examples, and ended up with this (failinmg) linq query:

   var defaultCategories = (from cats in Db.categories
                                 join defaults in Db.payee_default_category on cats.category_id equals
                                     defaults.category_id
                                     into merged
                                 from results in merged.DefaultIfEmpty()
                                 select new {cats.category_id, cats.description}).ToList();

So, I need to get ALL items in my Categories table, join to a payee_default_category on Categories.category_id = Payee_Default_Category.Category_id, and return the Category_id, the Category.Description, and a boolean of if there is a record in the payee_default_category table.

However, (overlooking the fact that I am not showing if there is a matching record…) at runtime, I get an error:

“LINQ to Entities does not recognize the method ‘System.Collections.Generic.IEnumerable1[Data.payee_default_category] DefaultIfEmpty[payee_default_category](System.Collections.Generic.IEnumerable1[Data.payee_default_category])’ method, and this method cannot be translated into a store expression.”

  • 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-19T13:54:02+00:00Added an answer on May 19, 2026 at 1:54 pm

    First of all, the DefaultIfEmpty method is not supported in version 1 of Entity Framework, but it is supported in version 4. You may want to upgrade.

    Secondly, since you’re only looking for a boolean to determine whether there are any defaults, you aren’t doing a real outer join so much as an “exists,” and you should be able to achieve it like this:

    var defaultCategories = 
       (from cats in Db.categories
        let defaults = Db.payee_default_category.Where(
            d => d.category_id == cats.category_id)
        select new {cats.category_id, cats.description, hasDefaults = defaults.Any()})
        .ToList();
    

    Also, your Entity Framework context would ideally be set up with table mappings, which would make your query even simpler:

    var defaultCategories = 
        (from c in Db.categories
         select new {c.category_id, c.description, 
             hasDefaults = c.payee_default_categories.Any()})
        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Follow up question to this: Linq Combine Left Join Data Say I have the
Using extension syntax I'm trying to create a left-join using LINQ on two lists
Trying to do a left join in subsonic using linq but it doesn't seem
I'm trying to do a left join in subsonic 3 using linq but it
I am trying to mimick the left outer join here but using dynamic linq
I have a MySQL Left Join problem. I have three tables which I'm trying
I'm trying to get a paged query to work properly using LINQ and NHibernate.
I'm trying to build a HQL that can left join values from a collection,
I'm trying to place this menu on the left hand side of the page:
Ok SQL and Oracle gurus I have a somewhat complicated query that I'm trying

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.