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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:06:44+00:00 2026-06-09T16:06:44+00:00

If I have a list like this: var teams = new List() { Team

  • 0

If I have a list like this:

var teams = new List() { "Team A", "Team B", "Team C" };

And I have a data set with scores like this:

var scores = new List<scoredata> {
    new scoredata() { Team = 'Team A', Date = '1/1/2012', Value = 1 }, 
    new scoredata() { Team = 'Team B', Date = '1/1/2012', Value = 1 }, 
    new scoredata() { Team = 'Team C', Date = '1/1/2012', Value = 1 }, 
    new scoredata() { Team = 'Team A', Date = '1/2/2012', Value = 2 }, 
    new scoredata() { Team = 'Team B', Date = '1/3/2012', Value = 3 }, 
    new scoredata() { Team = 'Team C', Date = '1/4/2012', Value = 4 }
}

Is it possible to construct a data set that looks like this?

Team A, '1/1/2012', 1
Team B, '1/1/2012', 1
Team C, '1/1/2012', 1
Team A, '1/2/2012', 2
Team B, '1/2/2012', null
Team C, '1/2/2012', null
Team A, '1/3/2012', null
Team B, '1/3/2012', 3
Team C, '1/3/2012', null
Team A, '1/4/2012', null
Team B, '1/4/2012', null
Team C, '1/4/2012', 4

I’m not sure what this is called, but I want to fill out blank dates and scores in my final dataset so that it always returns all Teams for each date, but if score data is not available returns null.

  • 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-09T16:06:46+00:00Added an answer on June 9, 2026 at 4:06 pm

    Using pure LINQ to Objects.

    public class ScoreData
    {
        public string Team { get; set; }
        public string Date { get; set; }
        public int? Value { get; set; }
    }
    
    var teams = new[] { "Team A", "Team B", "Team C" };
    var scores = new[]
    {
        new ScoreData { Team = "Team A", Date = "1/1/2012", Value = 1 }, 
        new ScoreData { Team = "Team B", Date = "1/1/2012", Value = 1 }, 
        new ScoreData { Team = "Team C", Date = "1/1/2012", Value = 1 }, 
        new ScoreData { Team = "Team A", Date = "1/2/2012", Value = 2 }, 
        new ScoreData { Team = "Team B", Date = "1/3/2012", Value = 3 }, 
        new ScoreData { Team = "Team C", Date = "1/4/2012", Value = 4 },
    };
    
    var dates = scores.Select(score => score.Date).Distinct();
    var query =
        from date in dates
        from team in teams
        join score in scores
            on new { Team = team, Date = date }
            equals new { score.Team, score.Date }
            into filteredScores
        let defaultScore = new ScoreData
        {
            Team = team,
            Date = date,
            Value = null,
        }
        from score in filteredScores.DefaultIfEmpty(defaultScore)
        select score;
    

    Note, this most likely won’t work as-is in LINQ to SQL or LINQ to Entities, it will need some tweaks.

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

Sidebar

Related Questions

I have a list of hierarchical data like this: var list = new List<Data>(){some
I have an ordered list like this: var list = new List<String>(){aaa,aab,aac,baa,bab,bac}; I want
Suppose I have a list of strings, like this: var candidates = new List<String>
So i have a List of strings that looks like this: var ls=new List<string>()
I have some LINQ code that generates a list of strings, like this: var
I have a list like this Dim emailList as new List(Of String) emailList.Add(one@domain.com) emailList.Add(two@domain.com)
I have a list like this: <select name=select_list_name id=list_id> <option value=>Select Option</option> <option value=value1>Option
Let's say you have a JavaScript class like this var DepartmentFactory = function(data) {
I have code in my list page something like this: <g:each in=${clientTripInstanceList} status=i var=clientTripInstance>
I'm somehow confused: I have a list of commands like this: var commands =

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.