Note that there are some explanatory texts on larger screens.

plurals
  1. POlinq issue with creating relationships
    primarykey
    data
    text
    <p>Seems I have a slight problem with my linq, I have a datacontract for Groups and I have a seperate datacontract for messages. Messages can be part of a Group. However when I update a message record its not reflected when I list the group information, the message is still the same for that group. But yet the update is reflected when I directly list messages?</p> <p>This is how I add a message to a group:</p> <pre><code> //lists for reference: List&lt;Group&gt; Groups = new List&lt;Group&gt;(); List&lt;Message&gt; messages = new List&lt;Message&gt;(); //not sure the below method is correct for adding a message to a group public void AddMessagetoGroup(string group, string messageID, string message) { var result = Groups.Where(n =&gt; String.Equals(n.GroupName, group)).FirstOrDefault(); var result1 = messages.Where(n =&gt; String.Equals(n.MessageID, messageID)).FirstOrDefault(); if (result != null) { result.GroupMessages.Add(new Message() { MessageID = messageID, GroupMessage = message }); } if (result1 != null) { result1.MessageGroup.Add(new Group() { GroupName = group }); } } </code></pre> <p>Seriously dont understand whats going on, if I add the message to the group any changes I make to the message should be reflected. The only thing I can think of is its adding a new instance of the already existing message, which means my update method is only copying the message, but where is this new copyed record even held. If its to difficult to fix how could I update the message that has been copyedTo/added to the group instead (cheap workaround)? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload