Advice on putting putting Entity Filtering/Sorting funtions in an Entity Class

Posts   
 
    
cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 02:32:45   

I'm used Adapter. I've made a few "GetEntities() funtions (Example: GetActiveEntities, GetHiddenEntities, GetAllEntites)

My Question:

Can I put such funtions in it's own Entity Class? (As a partial) Does that cross the bounds of DBGeneric / Specific?

Sounds kind of self referencing?

Advice would be helpfull.

Thanks CM

http://www.screencast.com/users/chris.m/folders/Jing/media/7bdfde01-c40e-465a-9690-26d566646d91

psandler
User
Posts: 540
Joined: 22-Feb-2005
# Posted on: 05-Jul-2009 05:15:33   

That screencast thing is very cool. How easy/hard is that to set up? Do you talk as you code or code then overlay the talk? Or can you do it either way?

To me it makes no sense to have the fetching done by the entity itself. When using adapter, persistence is generally modeled as a service, not as behavior on the entity itself. So I would say that in general it would not be a best practice and is sort of going against the intent of the generated classes.

That said, it seems like it's possible, and if it solves a particular problem or meets a particular need, there's no reason why you shouldn't do it. simple_smile

Have you looked at taking a Manager Class approach? Some searches on this forum should yield pretty good info on doing it this way.

HTH,

Phil

cmprogrock
User
Posts: 40
Joined: 16-Nov-2008
# Posted on: 05-Jul-2009 13:16:28   

Hi Phil, Thanks for the input. I think you're right. I looked at a Manager Class & this makes the most sense. As for the video cast thing - its 'Jing' form TechSmith...(jingproject.com). It's free, totally unobtrusive & makes creating these quick videos easier than email. Highly recommend it.

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jul-2009 22:30:38   

Depending on what are you doing, Manager Classes is definitely an option.

Also, in SelfServicing is very common to put these kind of methods in a partial class o at a derived class. For adapter it is not, because the persistence info is in the Adapter object, so for Adapter better if you use Manager Classes.

To understand the difference between TemplateSets, please read this.

David Elizondo | LLBLGen Support Team