T4 POCO Solution

Posts   
 
    
morphman
User
Posts: 28
Joined: 27-Oct-2011
# Posted on: 27-Oct-2011 17:04:50   

I've asked this same question on stackoverflow (http://stackoverflow.com/questions/7913266/t4-for-generating-pocos-over-llblgen-pro-entities) and haven't had any luck yet. A colleague of mine suggested I post here as well.

As I understand it, LLBLGen Pro cannot generate POCOs over it's own entities (see here: http://www.llblgen.com/Pages/featuresLLBLGenPro.aspx).

We tried using Microsoft EF and NHibernate and while their actual ORM solution wasn't robust enough, we did like their POCOs. Has anyone written a T4 that will generate POCO classes corresponding to LLBLGen Pro entities and generate the appropriate transformation logic to go to and from an entity and POCO? Has anyone else come up with a solution that doesn't involve manually writing tons of transformation code?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Oct-2011 05:01:41   

morphman wrote:

Has anyone written a T4 that will generate POCO classes corresponding to LLBLGen Pro entities and generate the appropriate transformation logic to go to and from an entity and POCO? Has anyone else come up with a solution that doesn't involve manually writing tons of transformation code?

No AFAIK. Here is a good thread about why this is not supported: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=16753 Is there any reason why this (POCO) is a must-have for you?

David Elizondo | LLBLGen Support Team
morphman
User
Posts: 28
Joined: 27-Oct-2011
# Posted on: 01-Nov-2011 19:50:46   

Your question of "why" we want to use POCOs is actually a pretty good one. I think there are two main reasons why we've been using POCOs in the past. One is an OK reason, the other is not a very good one:

1) We want(ed) to keep our business layer vendor agnostic. This is the "OK" reason. However, after doing some soul-searching we aren't sure it's worth the effort to try and keep LLBLGen Pro entities out of the business layer.

2) The less good reason is that we often times just used POCOs as business objects that made it out of the business layer--even if they were less simple than they needed to be.

In other words, I think we are OK without auto-generating POCOs. We'll just manually create simplified business objects when we need them and we'll use the LLBLGen Pro entities everywhere else.