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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:06:18+00:00 2026-06-06T17:06:18+00:00

I’m developing an app that has a model using race results / times etc..

  • 0

I’m developing an app that has a model using race results / times etc..
I’ve got a model that looks something like:

public class Competitor
{
    public int ID { get; set; }
    public string Name { get; set; }
    public DateTime DateOfBirth { get; set; }
}

public class Event
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}

public class Result
{
    public int ID { get; set; }
    public decimal ResultTime { get; set; }
    public Competitor Competitor { get; set; }
    public Event Event { get; set; }
}

I’m planning on flattening this for storing into mongo db, like this:

public class ResultSchemaExample
{
    public int CompetitorID { get; set; }
    public string CompetitorName { get; set; }
    public DateTime CompetitorDateOfBirth{ get; set; }
    public int EventID { get; set; }
    public string EventName { get; set; }
    public string EventDescription { get; set; }
    public int ResultID { get; set; }
    public decimal ResultTime { get; set; }
}

My concern is, this is going to make querying further up a little harder?
Is there a way I can classMap this to make it easier?

So I could do queries like:

var query =
    collection.AsQueryable<Result>()
    .Where(r => r.Name == "Alex");

And it would query my underlying, flat (non embedded) data to return instances of Result?

Is this possible?

Or, shall I just use my ResultSchemaExample across my app?

  • 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-06T17:06:19+00:00Added an answer on June 6, 2026 at 5:06 pm

    You could always have a composition class like this and store this in mongodb.

    public class RaceResults
    {
      public Competitor Competitor { get; set;}
      public Event Event { get; set;}
      public Result Result { get; set;}
    }
    

    Your query would then look like this:

    var query = collection.AsQueryable<RaceResults>().Where(r => r.Result.Name == "Alex");
    

    However, I would probably suggest a different schema entirely… Starting at your domain, I’m sure there is a rule that states that you cannot have a Result without an Event. That would lead me to design your domain slightly different; more like this:

    public class Event
    {
      public string Name { get; set; }
      public string Description { get; set; }
      public IList<Result> Results { get; set; }
    }
    
    public class Result
    {
      public Competitor Competitor { get; set; }
      public TimeSpan ResultTime { get; set; }
    }
    
    public class Competitor
    { ... }
    

    With this schema, you would have only 1 collection in mongodb: events. Each event would contain all the data it needs. Correlating competitor’s results across events would be fairly simple as well because mongodb supports querying inside arrays and documents. So the below query would get all the events where competitor 42 competed:

    var collection = db.GetCollection<Event>("events");
    var query = Query.EQ("Results.Competitor.Id", 42);
    var events = collection.Find(query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.