Can an entity have fields *not* from the database?

Posts   
 
    
JeffV
User
Posts: 4
Joined: 07-Aug-2006
# Posted on: 13-Dec-2006 23:25:19   

I have an "Issue" table and an "Assignment" table. The assignment of an issue is tracked in the Assignment table with IssueId, UserId, AssignmentDate, etc. The Issue table does not have an AssigneeUserId field, but I would like the Issue entity to have an AssigneeUserId field. The Issue/Assignment relation is 1:n and I only want the latest assignment. I know I can drill down and filter to get the value, but can I attach it to the Issue entity (maybe when the entity initializes?).

Can you add a dynamic field to an entity? Is this the right approach? I have searched and couldn't find an example which leads me to my next question. Am I doing something bizarre? I'm an overlooking an obvious answer? simple_smile

Thank in advance for your help, Jeff

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Dec-2006 06:34:11   

If the relation was the opposite m:1 instead of 1:m, I would have suggested using "Filed mapped on related field"

But in your case, you may create a custom property within the generated entity class. (use the appropriate "user code region").

Then you may chose your way (WHEN) to populate this property. Normaly you should do a normal fetch with filters to get the needed value.