Custom Property in an Entity

Posts   
 
    
luciusism
User
Posts: 119
Joined: 02-Jun-2007
# Posted on: 20-Oct-2007 20:17:09   

I feel I'm having a difficult time articulating this, let alone searching for it on the forums, so if this has already been discussed, please forgive me.

I have an LLblgen entity CUSTOMER that I'd like to add several custom properties. The properties would return CUSTOMER membership status. For example, if customer a member of PREFERRED BUYERS list, then property Customer.isPreferredBuyer return true. I can add the private/public members directly in the code generated Entity class, but not sure how I would set the value. (A query to a typed view passing the customer's id)

Is this something that should be done in the business logic layer, encapsulating the customer entity or can the type view be called in the custom code region of the customer entity? (In which case, not sure how I'd reference the customer id w/in the customer entity)

My preference would be to add the code to the Entity directly just b/c I'm updating an existing project where I use the customer entity all over the place.

Thanks!!

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 20-Oct-2007 23:28:18   

luciusism,

Based on the information given, I would create the custom property (I would recommend using a partial class instead of the user code regions), then when you fetch the Customer, have an extra step that runs your isPreferredBuyer query and sets the property (and at that point, you should have the customerId already).

Would it be possible to fetch the view as part of the customer using a prefetch path? That would be a cleaner solution IMHO.

HTH,

Phil

luciusism
User
Posts: 119
Joined: 02-Jun-2007
# Posted on: 21-Oct-2007 17:35:06   

Hi psandler, thanks for the reply! I will look into the partial calss to see if that fits my needs. Good point on prefetching. I wasn't doing that since the isPreferredBuyer is set by customer's membership in a list OR, customer's company's membership in the list.

thanks again!