This is a migrated thread and some comments may be shown as answers.

DTO Generator and Mapper

25 Answers 807 Views
Feature Requests
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Josiah
Top achievements
Rank 1
Michael Josiah asked on 26 Feb 2010, 09:55 AM
What would really be nice is if OpenAccess had a tool that allowed us to generate basic Data Transfer Objects with an accompanying mapper to map it back to OA entities.

25 Answers, 1 is accepted

Sort by
0
Dimitar Kapitanov
Telerik team
answered on 12 Mar 2010, 10:54 AM
Hello Michael Josiah,
We are starting to work on that, this is exactly the same as our idea where we should go in the future. We will do that I guess even prior to Q2 2010 release.

Regards,
Dimitar Kapitanov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael Josiah
Top achievements
Rank 1
answered on 14 Mar 2010, 09:23 AM
This would be great. How do you see it working exactly. For instance I would expect that my BLL would retrieve data from the database in the form of OA entities then convert them into DTO and send them to the UI or Service Layer. Then I could make changes to the DTO object pass them back to the BLL and have that convert it into OA Entities and save the changes. If this is what you have in mind then GREAT. This would be really beneficial for me and my small team. For instance I would really like to code the following in the UI

Dim Customer as new dtoCustomer
Customer.Firstname = "Michael"
BLL.CustomerManager.SaveCustomer(Customer)


So now in my BLL I would somehow convert the dtoCustomer into OACustomer and save the details. To me this is a really clean way of doing things as now my ServiceLayer and UI Layer will not need to know anything about OA and my BLL can deal with all the OA logic. This is pretty much the only thing stopping me from using OA, so I would greatly appreciate this. Please let me know if this is close along the lines to what your planning.

Thanks


0
Dimitar Kapitanov
Telerik team
answered on 23 Mar 2010, 07:04 PM
Hi Michael Josiah,
Yes this is exactly the idea we have, just the API will be maybe a bit different. Sorry for the late reply we are really gearing up for the next maintenance release we will make few weeks from now.

Best wishes,
Dimitar Kapitanov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
IT-Als
Top achievements
Rank 1
answered on 26 Mar 2010, 01:43 PM
Hello Michael and Dimitar,

This would really be great. We are doing this all the time in our WCF archiecture right now. On lower layers (business and repository) work is done on the OA persistent instances, but before anything goes up to the WCF layer on top of the business layer OA persistent instances are converted to a DataContract class instance.
The DC class instance pretty much mimics the properties of the "real" persistent object. However, in some situations things are done to "tweak" the DC class:

1) Get rid of back references in 1:m relationships.
When you have a highly navigation persistent model, where you can navigate in all directions your DC class might not need this. For example when you have and Order->OrderLines relationsship you can have a collection on the Order class and a reference back to the Order on the OrderLine class on the persistent level... but on DC level, you only need the Order-OrderLines navigation..thus you never (on DC level) go from OrderLine to Order
These cyclic references must indeed be avoided (if you don't wanna do anything special during serialization) when using WCF, since serialization will go on and on forever.

2) "Mark" which properties you want in the DC class from the original persistent object
Either do this by convention (name of property for example) or configuration (attribute on the PC class field, which describes what DC class this pc field maps to)

The ideal signature could be something like this:

// Mapping from a pc class to a dc class (full customer object as DC)
DC.Customer customer = Mapper<PC.Customer, DC.Customer>.Map(pcCustomerInstance)

// Mapping from a pc class to a dc class (simple customer object as DC)
DC.Customer customer = Mapper<PC.Customer, DC.SimpleCustomer>.Map(pcCustomerInstance)

Where the two generics in the last is the Persistent class you want to map from and the DC class you want to map to. If you use the first signature you'll get the full conversion to the DC.Customer

Similar you can do it the other way around when you want to map from DC class to PC class

PC.Customer customer = Mapper<DC.Customer, PC.Customer>.Map(dcCustomerInstance)

Just my few cents...

Regards

Henrik

0
Dimitar Kapitanov
Telerik team
answered on 08 Apr 2010, 05:38 PM
Hi Guys,
Thanks for the suggestions, they will be taken into account when we progress further with this development.

Greetings,
Dimitar Kapitanov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sörnt Poppe
Top achievements
Rank 1
answered on 12 Apr 2010, 08:33 PM

Have a look at Automapper:

http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx

http://automapper.codeplex.com/Wikipage
0
Dimitar Kapitanov
Telerik team
answered on 13 Apr 2010, 01:11 PM
Hello Sörnt Poppe,
Thanks for the suggestion will do.

Greetings,
Dimitar Kapitanov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 17 Mar 2011, 04:04 PM
Hi

sometime ago I wrote this to you guys:

"I know that on the next release, Open Acess will have automatic DTO's. So instead of creating the Assembler classes for transforming the Open Access data objects to our BO's, this will be done automatically correct?. Can you unveil anything about how it's going to work?"

Your answer was

"Unfortunately the DTOs will not be released together with the Q2 release as we didn't had the time to finalize all development there. However we will ship that really soon after the Q2 release. I would not go into details, except that we took the same approach as EntityFramework, and all such "upper layer" implementations will be released as T4 codegeneration templates, maybe together with wizards and helpers libraries. This approach allows really quick and succesful triage and problem resolution on your side - that way you will be able to fix/alter a lot of stuff even without waiting for an official drop of the templates. I hope that sheds some light on our intentions."

Any good news about the Automatic DTO's feature? We are already in Q1 2011...

Thanks.
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 18 Mar 2011, 04:05 PM

There was a sample a few months back:

http://www.telerik.com/support/kb/orm/general/dto-templates-for-domain-models.aspx

If been using a customized version of that, however the 2001 Q1 release breaks those templates. I'm currently looking into using custom code generation to get the Dto classes generated along with the normal classes. I might share that when I'm done.

I've got a feature related request though. I'd like to be able to set custom properties on classes and fields in the model designer, so I can use these properties in my own templates. One of the things I want to do is to use that to decide whether certain collections should be included in the Dto.

0
Sörnt Poppe
Top achievements
Rank 1
answered on 18 Mar 2011, 04:28 PM
My very personal opinion:

Looks like that those features takes forever to be included into that product.

I got the feeling that the OA Product didn't have the attention like the UI controls Products.
I for myself switched a year ago to Lightspeed (Mindscape) I am happy with them.
0
Alexander
Telerik team
answered on 22 Mar 2011, 06:08 PM
Hello,

We are currently working on the new templates, which will work with the Q1 version of OpenAccess. In this version we have introduced a few breaking changes in the code generation which make the current dto templates unusable. The new templates will be uploaded tomorrow, please excuse us for the delay.

Regards,
Alexander
the Telerik team
0
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 24 Mar 2011, 05:12 PM
These templates don't work with OpenAcess Free Version. I get the following error in VS 2010:

Error 3 Compiling transformation: 'Microsoft.VisualStudio.TextTemplating6B22AE572AF3D1455862D16725A4CA42.GeneratedTextTransformation' does not contain a definition for 'MetaModel' and no extension method 'MetaModel' accepting a first argument of type 'Microsoft.VisualStudio.TextTemplating6B22AE572AF3D1455862D16725A4CA42.GeneratedTextTransformation' could be found (are you missing a using directive or an assembly reference?) h:\MyPath\Includes\General.ttinclude 21 24 Miscellaneous Files

Any solution? Thanks.
0
Alexander
Telerik team
answered on 25 Mar 2011, 01:49 PM
Hi Hugo Augusto,

The currently uploaded templates do not work with the Q1 version of OpenAccess. Unfortunately we are experiencing some technical problems with uploading the new templates in the KB article, that is why I have attached them to this post.
Please note that the Includes folder is no longer needed in the project, you need only the Telerik.OpenAccess.DTO.tt file. Just make sure the file paths on lines 19 and 24-28 are correct and you can replace the old template with the new one. I hope that helps.

Kind regards,
Alexander
the Telerik team
0
LordRevan007
Top achievements
Rank 1
answered on 01 Jun 2011, 09:26 PM
Also I tried the dto templates that were given on the site, on Visual Studio 2008 and there were some errors because of the language C# in my case, I think in General.ttinclude template. Tomorrow I will provide the full error log, right now I am not at the computer I worked on.
0
Alexander
Telerik team
answered on 02 Jun 2011, 02:44 PM
Hi LordRevan007,

In fact this problem has already been fixed. The language="C#v3.5" attribute was missing from the first line of the template, which caused those transformation problems in Visual Studio 2008. The updated templates can be downloaded from the KB article.

Kind regards,
Alexander
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
0
Gianni Araco
Top achievements
Rank 1
answered on 26 Nov 2011, 11:23 AM
Greetings everyone.
The DTO generator and mapper was working smoothly until I updated to Q3 2011.
Now, no matter how many times I change the template or run the "Run custom tool" from the context menu, nothing happens.

Is there a fix for this?
Thanks very much.
Gianni Araco.
0
Ivailo
Telerik team
answered on 29 Nov 2011, 03:54 PM
Hello Gianni,

Are you using the DTO templates that were provided in the Knowledge Base article mentioned earlier in this thread? If that is the case, they should be compatible with the new release, so let us know what are the issues and we will assist you in resolving them. Try saving the template and send us any errors that occur.

Apart from those templates and following the great client interest in enhancing the Data Services Wizard, in Q3 release we have introduced a new OpenAccess ORM add-in, which will cover many of the features the Data Services Wizard lacks, like the DTO generation. The add-in is in beta version for the time being, therefore we are still shipping the DSW. However, since it fully supports WCF plain services by automatically generating DTO files, you can give it a try and let us know for your experience. You can start it through a context menu item of the RLINQ file or an ASP.NET project named "Generate OpenAccess Domain Model Service...".

I am looking forward to your feedback.

Kind regards,
Ivailo
the Telerik team

Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Gianni Araco
Top achievements
Rank 1
answered on 04 Dec 2011, 09:55 AM
Greetings Ivailo.
Sorry for the long delay.
I confirm that the template is working.
It is a problem between Visual Studio 2010 and Team Foundation Sever. When I run the template on checked-in files, it doesn't ask for check-out, nor says anything, so it seem it's not doing anything.

Best regards.
Gianni Araco
0
Gianni Araco
Top achievements
Rank 1
answered on 04 Dec 2011, 09:55 AM
Greetings Ivailo.
Maybe I've been a bit too eager to answer.
I have created a new project, and it created the files accordingly (hence the above answer).
But I need to modify an existing one. I checked-out all the autogenerated files, as well as the .tt, and run it.
I tryed even modifying the file (adding a character at th end of a line) and saving it.
In both cases, nothing happened, though in the .rlinq some tables have been changed. Only the Telerik.OpenAccess.DTO.cs have been regenerated.

I tried two more drastic procedures: remove and add the .tt again and create and entirely new project.
Surprise surpise... it didn't work! Now it doesn't generate anything... I'm rather puzzled.
In the new project, I tried refering to a different .rlinq and it worked. So it must be something in there.
But the rlinq project compiles without errors...

The .rlinq that worked has been generated after the installation of Q3, while the one that is not working was generated with Q2.
I've checked the project file, and it refers to the new .dll versions.

Out of desperation, I've tried creating a new .rlinq file for that database  and... well, it doesn't generate the persistence class files!
I've had to remove the  .rlinq from the project and create it again adding it as Telerik OpenAccess Domain Model file...

I'd gladly avoid having to create a new project just to update the DTOs, so If you have any advice, it will be much appreciated.

Thanks and best regards.
Gianni Araco
0
Ivailo
Telerik team
answered on 06 Dec 2011, 12:43 PM
Hello Gianni,

I would recommend you to use the new add-in I have mentioned in my previous post to generate your DTOs, instead of the templates. I think it will save you some time.

In case you prefer to carry on with the templates, let me know and I will change your forum post to another type of ticket communication so that you will be able to attach an archive with the problematic data access project and we can examine what exactly went wrong.

All the best,
Ivailo
the Telerik team

Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Norbert
Top achievements
Rank 2
answered on 27 Feb 2012, 06:05 PM
Hello,

I want to generate DTOs out of the rlinq file but when I call the context menu there is nothing to choose...?!
I've the model and the context separated in two projects (dll's)

Thank you for help,
regards Norbert
0
Serge
Telerik team
answered on 28 Feb 2012, 10:24 AM
Hello Norbert,

 Which version of OpenAccess do you have installed? We released the new Generate OpenAccess Domain Model Service wizard with the Q3 2011 release. You should also note that it is only available under Visual Studio 2010.

Also there is a somewhat sporadic known bug where sometimes the menu item is called "MRU Placeholder..." instead of the regular "Generate OpenAccess Domain Model Service...". 

I hope this helps. 

Kind regards,
Serge
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
0
Jiri
Top achievements
Rank 2
answered on 22 Mar 2012, 09:09 AM
Hello everyone,

I'm using latest version of T4 template for DTOs generation and in my datamodel I'm using vertical inheritance strategy for two tables.

The problem is that the DTO class code is generated correctly but the ancestor for the DTO class is not DTO class but the model class. I'm not so experienced with T4 templates and was not able to find out how to change the T4 template to do this. Can anyone give me a clue ?

Many thanks

Jirka

--edited
And there's also issue with generation of the Repository class ...
0
Serge
Telerik team
answered on 27 Mar 2012, 09:44 AM
Hello Jiri,

 The templates used for generating a DTO layer, currently have trouble generating a model that has inheritance included. While we produce some results this a known issue that we will be working on for Q2. We are planning to getting the wizard out of beta by then, so any feedback about issues or things that can be improved will be welcomed.

It can turn out that implementing the inheritance support is quite some work. However these templates are intended to kick start your development. You shouldn't have much trouble modifying the generated code to serve your purposes. Keep in mind though that you might get your changes overridden if you generate the DTOs again. 

I hope this helps.

Regards,
Serge
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
0
Jiri
Top achievements
Rank 2
answered on 03 Apr 2012, 08:07 AM
Hello Serge,

thanks for your answer. I'm actually using the procedure which you had described :) I was just wondering if there's another way how to acomplish this.

Looking forward for Q2 - or any usable beta version :)

Best regards

Jirka
Tags
Feature Requests
Asked by
Michael Josiah
Top achievements
Rank 1
Answers by
Dimitar Kapitanov
Telerik team
Michael Josiah
Top achievements
Rank 1
IT-Als
Top achievements
Rank 1
Sörnt Poppe
Top achievements
Rank 1
Hugo Augusto
Top achievements
Rank 2
Iron
Veteran
Iron
Jakkie Esschert van den
Top achievements
Rank 1
Alexander
Telerik team
LordRevan007
Top achievements
Rank 1
Gianni Araco
Top achievements
Rank 1
Ivailo
Telerik team
Norbert
Top achievements
Rank 2
Serge
Telerik team
Jiri
Top achievements
Rank 2
Share this question
or