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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:07:36+00:00 2026-06-14T17:07:36+00:00

I have a situration where I have a class [Table(SomeTable)] public Class Thing {

  • 0

I have a situration where I have a class

[Table("SomeTable")]
public Class Thing
{
[Key]
public int Id { get; set; }
public string Description { get; set; }
public int ImAForeignKey { get; set; }
public bool HasStuff { get; set; }
}
...
...
public class ugly
{
public Thing Thing { get; set; }
public List<Thing> LotsOfThings { get; set; }
}

Where Thing is some EF class representing a table in a database…
I then want to create a collection of ugly:

List<ugly> gruesome;
using (var db = new ThingyDatabase())
{
gruesome = db.Thing
          .Where(r => r.HasStuff && r.ImAForeignKey == passedin.someFKvaluePassedIn )
          .Select(r => new ugly {
                     Thing = passedin,
                     LotsOfThings = ??
           })
    .ToList();
}

...

I unsure about how I populate the ListOfTHings property…. or if I can do it this way… I have an id that I am scouring Thing with and this id (foreign key) can have multiple records within Thing but one of the records is going to be the parent record and the rest of them are children. So what I would end up with is a collection of things with their children… hope this helps.

Any thoughts?

  • 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-14T17:07:37+00:00Added an answer on June 14, 2026 at 5:07 pm

    I ended up doing the following:

    List<ugly> gruesome;
    using (var db = new ThingyDatabase())
    {
      gruesome = db.Thing
          .Where(r => r.HasStuff && r.ImAForeignKey == passedin.someFKvaluePassedIn )
          .ToList();
    }
    
    var ughObj = new Ugly {
        Thing = passedin,
        LotsOfThings = gruesome
    }
    

    It gives me what I need the parent(passedin) and the children(gruesome)

    thanks all

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

Sidebar

Related Questions

I have this situation: public class busOrder: IbusOrder { public Order vOrder { get;
i have situation like this: class IData { virtual void get() = 0; virtual
I have a has_many :through relationship set up like so class Situation < ActiveRecord::Base
I have situation where I am mapping table's columns to the primary key of
I have the following multi-table inheritance situation: from django.db import Models class Partner(models.Model): #
I have a re-usable UITableViewController sub-class, call it tableVC. Selecting a table row pushes
I have table inheritance in database: Ticket{TicketId, TicketTypeId, CreatedBy, Title, Description etc.} UserInfo{TicketId etc.}
I have a situation utilizing class table inheritance where the base object (which is
Pseudo-situation: have a class (let's say BackgroundMagic ), and it has Start() and Stop()
I have the following situation : abstract class X { abstract X someMethod (...)

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.