Hi there. I hope to understand your situation. I would go for one of this options:
a. (easy one) Use a TypedList. In the designer create a TypedList and add the Comment, Ticket and Project entities, then add the fields you want. You then can make a poco object based on typed lists.
b. Modify your template. When you loop through the related objects, look if the related entity have also field mapped on related fields, if that happen, add then such fields to your poco object definition. It would be easier if you use .lpt template instead of TDL (limited for advance requirements).
c. If you opt for generate entities as is, and then generate your poco at runtime based on the entities, you can add a custom property as Walaa suggested. For instance:
public partial class CommentEntity
// this is a partial class of CommentEntity
{
public int ProjectId
{
get
{
int toReturn = 0;
if (Ticket != null && !Ticket.IsNew)
{
if (Ticket.Project != null && !Ticket.Project.IsNew)
{
toReturn = Ticket.Project.ProjectId;
}
}
return toRerurn;
}
}
// ...
}
That property is ready for databinding, and ready to use for other purposes, like query it in-memory or use it to populate a DTO or POCO object.