Projecting subclass on to a DataView

Posts   
 
    
peschkaj
User
Posts: 30
Joined: 21-Sep-2006
# Posted on: 12-Jan-2007 16:14:09   

I have added a property to a subclassed entity, the property is DaysLate and it has some internal calculations and null checks to determine how many days late an item is. However, when attempting to project this onto a DataView, I ran into an issue where there is no MyProjectItemFields (the base class is ProjectItemEntity). Is there a way to project my custom properties onto a DataView, or is there a better way to do this than projection?

Thanks,

Jeremiah

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 13-Jan-2007 02:32:33   

Is there any reason why you couldn't put this extra field in a user code region or in a partial class of the entity? This is how I usually handle calculated properties for entities.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 14-Jan-2007 09:36:21   

Use an EntityProperty instance to project the property you added yourself.

Frans Bouma | Lead developer LLBLGen Pro
peschkaj
User
Posts: 30
Joined: 21-Sep-2006
# Posted on: 16-Jan-2007 14:21:33   

So, essentially, I would want to do something like:

_propertyProjectors.Add (new EntityPropertyProjector (new EntityProperty ("DaysLate"), "DaysLate"));

And repeat that for any calculated fields that I want to include in the projection.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 16-Jan-2007 16:33:40   

Hello, when you use

_propertyProjectors.Add (new EntityPropertyProjector (new EntityProperty ("DaysLate"), "DaysLate"));

, your dataview doesn't contains the field or you have a runtime exception? If there is a runtime exception, could you post the call stack?

peschkaj
User
Posts: 30
Joined: 21-Sep-2006
# Posted on: 16-Jan-2007 17:04:00   

I'm not receiving any errors, I just wanted to post a code sample so that I could be sure I was doing the right thing.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Jan-2007 20:06:33   

That was a correct code example.