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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:17:40+00:00 2026-05-25T10:17:40+00:00

I am trying to construct an object containing several listings. The object – a

  • 0

I am trying to construct an object containing several listings. The object – a message – is represented by one table and the contained lists represented by one table each.

The problem is that when selecting messages, the properties supposed to reference the contents in the child tables all have a zero count even if there are values in the child tables.

I have simplified the database so that i only have one associated child table to provide a good example of the problem.

What I have:

  • One table called Messages that contains the following properties:

    • Id – uint – autogenerated – primary key
    • Message – string
  • One table called Recipients that contains the following properties:

    • MessageId – uint – primary key
    • RecipientId – uint – primary key
  • One association between these two. Messages is parent, recipients is child. Cardinality is one-to-many. Participating properties are Messages.Id -> Recipients.MessageId.

My objective is to be able to save messages. Each message should have one or more recipients. When i extract a message from the Messages table, i want the Recipients property (generated from the association to the Recipients table) to give me back all of the recipients where the MessageId equals the Id of the extracted message.

So, I insert into the database:

void SendMessage(string message, uint recipient)
{
  var m = new Message { Message = message };
  context.Messages.InsertOnSubmit(m);
  context.SubmitChanges();

  var r = new Recipient { MessageId = m.Id, RecipientId = recipient };
  context.Recipients.InsertOnSubmit(r);
  context.SubmitChanges();
}

Now, if i select the messages from the Messages table, i find the message. Its Recipients property has Count = 0. Somehow the association to recipients is not made. So I must do something wrong.

However – and this really confuses me – if i select the recipients from the recipient table, i find the recipient with the correct MessageId and RecipientId. The ORM framework has also generated a property that references the parent table and this one works! The Recipient entity’s Message property actually references the Message that is its parent.

Can anyone give me a hint on what I’m missing in order to be able to list all the child entities of a parent entity? Or on what more information one might need to give me an answer?

  • 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-05-25T10:17:41+00:00Added an answer on May 25, 2026 at 10:17 am
    private void SendMessage(string message, uint recipient)
    {
        var message = new Message { Message = message };
    
        //no need to explicit the relation with message
        var r = new Recipient { RecipientId = recipient };
        //add the recipient to message's recipients 
        message.Recipients.Add(r);    
    
        context.Messages.InsertOnSubmit(message);
        //only one submit is needed
        context.SubmitChanges();
    }
    

    As you found out by yourself, the auto-generated Message class has a Recipients property of type EntitySet<Recipient>, which is basically all the recipients associated to that message.

    If you add the recipient to the message you are going to save, LINQ will automatically associate it with the proper id key when submitting the changes.

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

Sidebar

Related Questions

I'm trying to construct a table with dynamically build information. My thought was to
I'm trying to construct a find command to process a bunch of files in
I'm trying to construct a query that will include a column indicating whether or
I am trying to construct a way to keep certain hard drive partitions/usb drives
I'm getting a byte array from a JNI call, and trying to construct a
I'm trying to programmatically set the constructor sting of a COM+ component from a
I am trying to define a WCF contract that returns an interface, something like
I'm trying to find a way to determine how many parameters a constructor has.
I'm trying to implement a KeyListener for my JFrame . On the constructor, I'm
I have a class which constructor takes a Jakarta enums . I'm trying 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.