khorvat wrote:
Hi,
sorry for late reply, forum notifications went to Gmail spam folder - for the first time in all these years. I have been using templates in previous projects and I had one project that we used ASP.NET GUI generator templates but this isn't what I'm looking for.
I need DTOs/Pocos/Models however you call them to be simple object generated in a 3rd class library project (so this is one) and then I need interfaces for these objects to be generated in 4th class library project.
The DTOs should be 1:1 representatives of the entities, without navigators? and you can save entities back?
Anyway, the template system works as follows: in a preset it adds all file names generated to a cache and all file names in that cache are added to a vs.net project file if that task is executed. The best starting point is the adapter preset, as it generates two vs.net projects and you can see the settings needed (e.g. clear the cache when the second project is generated). For DTOs and interfaces, you need to add two templates in a new task group with at the end in each task group a vs.net project template task like in adapter. One of the two templates simply generates a DTO, the other generates an interface. The DTO class implements the interface (which is simply named I<name> and the DTO is named <name>DTO)
To fetch them, you could use automapper, e.g. generate automapper mappings from the project using another template.
I need this in order to have onion architecture, IoC and DI where my upper layers don't know anything about LLBLGen. I think this is pretty straight forward scenario but I can't find a blog/article describing how to generate additional project beside existing ones ?
Is this the feature that will be available in v5 or ?
Thanks
In v5 you'll be able to define derived models on top of the entity model, denormalized or 1:1 that's up to you. You can choose between Document database class models (which require an id) and DTOs (which don't) and generate code from them in various forms. Your interface suggestion will be added to the list of projects we'll offer. The elements in the derived models will be hierarchical, so you can have an OrderDTO which contains a Customer object with e.g. limited info from a Customer entity.
We're not done with this feature (the code generation part and the last part of the modeling editor has to be done still) so I can only tell you what we've planned: using automapper we hope to achieve 2-way usage of the DTOs: fetching them and also persisting them (the root entity that is) however that last part might not always be available / work due to denormalization. Additionally, as there's typically no change tracking inside a DTO, the route back to the DB will require a fetch of a live entity which is then updated with the values in the DTO and then persisted.
As v5 is still in development, I'd suggest to first look at templates for v4. You can start by using DTO templates which have been posted on this forum. E.g. see: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=21592