I am trying to use a stored procedure to hydrate an object graph. Stored Procedures are required by the business. (Please don't recommend I switch)
I have an object called "Comment" which contains:
Comment
--CommentID
----CommentText
----FromUser
------UserID
------UserName
------Profile (One-to-one)
--------ImageURL
----ToUser
------UserID
------UserName
------Profile (One-to-one)
--------ImageURL
I am trying to hydrate specific properties on the Comment, FromUser, FromUser.Profile, ToUser, ToUser.Profile objects. There are two problems I am running into:
1. How to I map ToUser.UserID to the column "ToUserID" in the dataset returned by the stored proc?
2. How can I hydrate the Comment.ToUser.Profile object? Every documentation I've read shows hydrating a class one level below the top level, but no deeper in the object graph.
Here's my sql query mapping file (which is not valid at this point):
<sql-query name="MSG_CommentSearch">
<return alias="Comments" class="Comment" >
<return-property name="CommentID" column="CommentID"/>
<return-property name="FromUser">
<return-column name="UserID"/>
<return-column name="UserName"/>
</return-property>
<return-property name="ToUser" >
<return-column name="UserID" />
<return-column name="UserName"/>
</return-property>
<return-property name="CommentText" column="CommentText" />
<return-property name="PostDate" column="PostDate"/>
</return>
exec dbo.MSG_CommentSearch :Status, :IsCount, :Page, :PageSize, :OrderBy
</sql-query>
|