If I have one-to-many relation between two entities (ie. Post
and Comment
) and have my master class defined as:
public class Post {
...
IList<Comment> Comments { get; set; }
}
But my Comment
sub-related class doesn't have a property of type Post
, because there's never a need to get from comment to post. Comments are always displayed along with the master post instance.
Then I have a stored procedure that returns two result sets: posts and comments that are related to them. I define my MapResultSet
as
MapResultSet[] sets = new MapResultSet[2];
sets[0] = new MapResultSet(typeof(Post), posts);
sets[1] = new MapResultSet(typeof(Comment));
sets[0].AddRelation(sets[1], /* what goes here? */, "PostID", "Comments");
But this doesn't work, since Comment
doesn't have a reference to its Post
hence I don't have anything to define for the second parameter in the upper code. If I provide string.Empty
or null
I get an exception if invalid method parameter.
How should I define relationship between these two entities without adding a Post
property to Comment
?