Trying to use BLToolkit mapper in my project. There is a thing that I really don't know how to solve , the deal is that I have 2 classes Content and Comment.
[MapField("CommentItemId","CommentContent.ContentId")]
public class Comment
{
[MapField("Comment.CommentId")]
public int CommentId;
[Relation(typeof(Content))]
public Content CommentContent;
}
public class Content
{
[MapField("ContentId"),PrimaryKey]
public int ContentId;
public IList<Comment> Comments = new List<Comment>();
}
Well , looks as simple Complex Mapping as example that everybody saw on BLToolkit.net . But , I'm trying to use SELECT JOIN query. This is my query.
MapResultSet[] sets = new MapResultSet[2];
sets[0] = new MapResultSet(typeof(Content));
sets[1] = new MapResultSet(typeof(Comment));
command = String.Format(@"SELECT con.ContentId,com.CommentId,com.CommentItemId
FROM Content as con,Comments as com
WHERE (con.ContentId = com.CommentItemId AND con.ContentId {0})", itemid, type);
This query returns correct data ( checked with ExecuteReader ). But in MapResultSets there is only Content data , no Comment data ... If i will interchange Content and Comment sets ... I will get only Comment data , and no Content data ... I don't even care about realtions right now , i just want to explain to BLToolkit , that there is data of 2 classes in 1 row.