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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:20:03+00:00 2026-06-09T08:20:03+00:00

Let me start to explain with an example. var vProducts = new[] { new

  • 0

Let me start to explain with an example.

var vProducts = new[] {
    new { Product = "A", Location ="Y", Month = "January", Demand = 50 },
    new { Product = "A", Location ="Y", Month = "February", Demand = 100 },
    new { Product = "A", Location ="Y", Month = "March", Demand = 20 },
    new { Product = "A", Location ="Y", Month = "June", Demand = 10 }
};

var vPeriods = new[] {
    new { Priority = 1, Month = "January" },
    new { Priority  = 2, Month = "February" },
    new { Priority  = 3, Month = "March" },
    new { Priority  = 4, Month = "April" },
    new { Priority  = 5, Month = "May" },
    new { Priority  = 6, Month = "June" }
};

var vAll = from p in vProducts
       from t in vPeriods
       select new
           {
             Product = p.Product,
             Location = p.Location,
             Period = t.Priority,
             PeriodName = t.Month,
             Demand = p.Demand
           };

This above query will create all combinations of Products & Period. But, I need to get a list of all products along with the ones that do not have matching Month as shown below.

example

Product      Location      Priority        Month    Demand
  A              Y            1           January     50
  A              Y            2          February    100
  A              Y            3           March       20
  A              Y            4           April       null
  A              Y            5           May         null
  A              Y            6           June        10

Thanks for any comments.

  • 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-09T08:20:04+00:00Added an answer on June 9, 2026 at 8:20 am

    You want to do a left outer join, it will go something like:

    var res = from period in vPeriods
                      join product in vProducts on period.Month equals product.Month into bla
                      from p in bla.DefaultIfEmpty()
                      select new { period.Month, period.Priority, Product = p == null ? null : p.Product, Demand = p == null ? -1 : p.Demand };
    
      foreach (var a in res)
                {
                    Console.WriteLine(string.Format("{0} {1} {2}", a.Product, a.Month, a.Demand));
                }
    

    Of course that products that do not have matching months don’t have locations etc. (as you stated in your example)

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

Sidebar

Related Questions

I realise this might be hard to explain, so let me start by using
Before you start laughing at such a simple question let me explain: I am
first let me start by saying I'm pretty new to iPhone, so I apologise
Let's start with the Hello World program detailed at http://developer.android.com/resources/tutorials/hello-world.html . Let's add the
Let me start by saying this is a homework assignment, I don't need any
Let me start by saying that I've never coded in Python. I need to
Let me start by saying, I like the border that chrome is using for
Let me start by telling you that I never used anything besides SVN and
Let me start out by saying that I'm not a C developer and I
Let’s start with this statement: We have published couple of free applications on 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.