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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:56:03+00:00 2026-06-07T10:56:03+00:00

In this msdn example: The .NET Standard Query Operators We see this example of

  • 0

In this msdn example:

The .NET Standard Query Operators

We see this example of a LEFT JOIN:

var custTotalOrders =
 from c in customers
 join o in orders on c.CustomerID equals o.CustomerID into co
 from o in co.DefaultIfEmpty(emptyOrder)
 select new { c.Name, o.OrderDate, o.Total };

And it says that:

where emptyOrder is an Order instance used to represent a missing order.

So, where does emptyOrder come from?
How can I use it in my code?

  • 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-07T10:56:07+00:00Added an answer on June 7, 2026 at 10:56 am

    There are two overloads for DefaultIfEmpty

    DefaultIfEmpty()

    DefaultIfEmpty(defaultValue)

    The first will return default(T) where T is the type contained in the enumerable when the enumerable is empty.

    The second will return the value given in the defaultValue parameter when the enumerable is empty.

    Assuming you declared emptyOrder like so:

    Order emtpyOrder = new Order() { Total=100 };
    

    Then in the query:

    var custTotalOrders =
    from c in customers
    join o in orders on c.CustomerID equals o.CustomerID into co
    from o in co.DefaultIfEmpty(emptyOrder)
    select new { c.Name, o.OrderDate, o.Total };
    

    When a customer did not have a matching order, the Total property in the projected anonymous object would have the value 100.

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

Sidebar

Related Questions

This is an Example from MSDN about Object Class in .NET FrameWork. using namespace
Why in this example from MSDN, in GetEnumerator method, PeopleEnum returns IEnumerator ? public
This is an example xml from MSDN <?xml version=1.0?> <!-- A fragment of a
I've tried this example directly from MSDN: Dim Screens() As System.Windows.Forms.Screens and I can't
So, this example comes right from MSDN. http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readelementcontentasbase64.aspx Pretty much the only thing I
I read this MSDN like about it and ran its example. http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.aspx when I
I can't find any example signatures for .NET to use this function (GetSystemDEPPolicy). http://msdn.microsoft.com/en-us/library/windows/desktop/bb736298(v=vs.85).aspx
I am using this example of the WMI: http://msdn.microsoft.com/en-us/library/aa390423%28v=vs.85%29.aspx I retrieved information from the
I used this MSDN example to construct my console host app: http://msdn.microsoft.com/en-us/library/ms731758.aspx It works
I looked at this example http://msdn.microsoft.com/en-us/library/bb399420.aspx and clicked on DataContext.CreateDatabase which brought me to

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.