Which features would you like to see in EntitiesToDTOs 4 ?

Coordinator
Nov 21, 2012 at 12:24 PM

Hello everyone.

I would like to know which features would you like to see in the future to be included in EntitiesToDTOs v4.0 ?

If a feature suggestion has more to talk I will open a discussion only for that feature, but first, please post your idea here.

Thanks for using EntitiesToDTOs !!!

Regards,
Fabian Fernandez

Marked as answer by ffernandez on 12/30/2013 at 6:58 PM
Nov 22, 2012 at 12:55 AM
Edited Nov 22, 2012 at 12:59 AM

I would really like to see interfaces.

 

Currently, it is difficult to create a generic method to Get a DTO by id from the repository.  See this work in progress function call below:

// eventually this can become an extension method
public EntityType GetDTOByID<EntityType>(MyEntities entities, string keyName, int id) where EntityType : class
        {
            var q = entities.CreateObjectSet<EntityType>().Where(string.format("it.{0} = @tableNameId", keyName));  // may need to use '?' instead of tags
            q.Parameters.Add(new ObjectParameter("tableNameId", id));
            var entity = q.Single();
            if (entity == null)
                return null;
            else
                return entity.ToDTO();  // cannot do this because we don't know what methods "EntityType" supports!!
        }

 

Here is another example:

public  DTOType GetDTOByPrimaryKey<EntityType, DTOType>(ExtendedATPEntities entities, int id) where EntityType : EntityObject where DTOType: IDTO //it would be really nice if we could do something like this
        {
            EntityType entity = GetByPrimaryKey<EntityType>(entities, id);
            if (entity == null)
                return null;
            else
                return entity.ToDTO();  // compile time error.
        }

Coordinator
Nov 22, 2012 at 11:26 AM
Edited Nov 24, 2012 at 4:06 PM

Hi Julio!

Let me review it this weekend with more time so I can come up with my comments.

Thanks for your suggestion!

Nov 23, 2012 at 11:00 AM

Hi ffernandez,

a feature in your tool to choose what properties goes into a DTO would be great! Because normally you only want to transfer really needed properties through DTO's and not the whole bunch of informations which are propably not needed (because performance and design reasons).

It would be also useful to store these kind of mapping informations in the configuration file, so that I can store it in version control system for example. In case of refactoring the mapping should be updated automatically (when possible).

Looking forward to your project!

Cheers

Coordinator
Nov 23, 2012 at 11:40 AM

Hi @sizilium !

Thanks a lot for your suggestion, definitely it will be included in the next release.

I have created this work item to track this new feature.


Thanks,
Fabian

Coordinator
Nov 27, 2012 at 9:07 PM

Hi @juliochristo

Thanks a lot for your suggestion, I've opened this discussion as I think that what you say can lead to more comments.

Mar 15, 2013 at 4:57 PM
Edited Mar 15, 2013 at 4:59 PM
ffernandez, here are a few thoughts regarding your tool. Would love to hear your input.
  1. I'm using "Class Types" associations for DTOs. Let's assume I have a ClassDTO with a collection of StudentDTOs. ClassDTO will have a List<StudentDTO>, each StudentDTO will have a reference to ClassDTO as well as the ClassId field which is the foreign key in the actual db table/entity. When I convert my entities to dtos, I usually do it top down, first I'll convert Class to ClassDTO, then I'll convert List<Student> to List<StudentDTO>, however I never assign back up the Class to each Student. What this means is ClassDTO.Students gives me all the StudentDTOs, but if I look at an individual Student, the ClassDTO reference on it is null. However if I were to manually populate it, WCF would throw an exception complaining about circular references. Long story short, would it be a good idea to perhaps have an option to not having the "navigation property" so to speak from the "1" to the "*" side? It's not a big problem but if a developer by mistake does what I described they will blow up the service without really knowing it.
  2. I generate my assemblers into Application.Services.Assemblers, which is part of my Application.Services library. My edmx lives in Application.DataAccess, however I move out my Entities after they are generated into Application.Model. When I generate my assemblers you automatically reference Application.DataAccess for me from Application.Services, which is NOT what I want. I realize why you do what you do, but I wonder if there is a way for me to specify not to reference the Application.DataAcess project, and also if I could replace the "using Application.DataAccess" statement with one of my own that I would supply myself, such as "using Application.Model".
  3. It would be cool to possibly have a "Preview" functionality. I don't know if you ever used something like Redgate's SQL Compare, but it let's you preview the SQL script before it applies it. Basically the use-case would be me looking at the preview and possibly Ctrl + C a section that I'm interested in and manually pasting it into my DTO or Assembler.
  4. Is it my or exporting/importing the config file doesn't actually save all of my selections? Maybe I'm misunderstanding what it's supposed to do.
Coordinator
Mar 15, 2013 at 6:48 PM
Edited Mar 15, 2013 at 6:48 PM
Hi @S52M3, thanks a lot for your suggestions, here are my comments:
  1. This Feature Request can mitigate that problem, let me know what you think.
  2. I created this Feature Request to overcome the problem you mention, good point.
  3. I created this Feature Request for the Preview, it is cool and could help w/o doubt.
  4. I don't know exactly what you are expecting to see in the config file but I can say that it works ok by now, you can send me an email directly if you want and include your config file and what you are expecting to see in it.
Thanks!
Apr 16, 2013 at 8:04 PM
ffernandez, two more things I thought of
  1. The ability to remove the timestamp from the generated classes, this is an issue if I choose to always regenerate my classes even though perhaps I only changed 1 or 2 classes. The problem is that source control thinks that all of them truly changed because of the timestamp and it checks in a new version every time for no good reason.
  2. When creating DTOs from entities that link to other entities, I'm forced to include all those other entities in regeneration otherwise the DTO will not include the navigation properties. This is a little annoying because I might have changed just one property on the entity, all of a sudden I need to include and regenerate the entire linked graph which could be half of my database. I wonder if there is a way to allow me to keep all those navigation properties without having to regenerate all the linked entities. With understanding of course that if those linked entities were never generated then I'll have broken code.
Thanks, keep up the good work.
Coordinator
Jun 28, 2013 at 2:30 AM
Edited Jun 28, 2013 at 2:31 AM
Hi @e36M3
Sorry for the too late response, been busy with other projects.
Here are my comments, thanks a lot for yours!
  1. I've created this work item for your suggestion. Great!
  2. Short answer: you have to select those entities, that's how I know which navigation proerties to include. Does it takes too much time to regenerate, is that the problem? Also, if the other entities have not changed then there's no need to worry about it.
Jul 1, 2013 at 2:26 PM
ffernandez, there are several reasons for #2. First of all I have to always check out the entire folder of DTOs and Assemblers otherwise visual studio will bug me to check out every single file which could be hundreds, if I were to only refresh the DTO I actually changed I wouldn't have to remember to do this every time. Second of all the issues I outlined in #1, which of course can be solved separately. The other thing is that if someone doesn't select all entities, perhaps by mistake, some of the navigation properties will be omitted, however my project potentially will build just fine, until I try to access my service from the front end and all of a sudden I notice that something is missing.

I just wonder if perhaps it would be possible to have a checkbox that says "include all navigation properties" for an entity even if I didn't select some of the entities that are linked to it. Basically the checkboxes right now mean "these are the only entities I will analyze and create DTOs based on what I saw" I wish I had the option that says "I will analyze the entire entities graph, however I will only output the DTOs selected by the checkboxes". Basically the checkbox would drive which DTOs are updated, but not which navigation properties will be analyzed on those entities/dtos. I don't know if it totally makes sense but it would look something like this:

I have the following entities: User, Password, History. User has navigation properties to both, User.Passwords, User.History. Lets say I added FirstName to user and I want to regenerate User. Today I have to select all 3 entities to be regenerated in order for my graph to be correct, but I really I just want to refresh User so I can get FirstName property on it. But if I only select User then the link to Password and History will be lost.

Let me know what you think.
Jul 4, 2013 at 7:58 PM
hi ffernandez

I would like to be able to create Folders within the solution directly from the E2DTO Dialog (instead of having to Close it middleway through the configuration to create the correct Folders first).
Jul 4, 2013 at 8:21 PM
Edited Jul 4, 2013 at 10:46 PM
hi ffernandez

I would like the ability to define either a base class like "BaseDTO" or an Interface like "IAssembler" or both upon generation.
An empty class is enough, nonetheless is needed for "generics", that every DTO or Assembler implements an interface.
For Assemblers an Interface would suit better, for DTOs maybe a base class is better.

public static partial class MyAssembler : IAssembler

public partial class MyDTO : BaseDTO
Jul 7, 2013 at 7:23 PM
hi ffernandez

I just found out that E2DTO does not Support the new Enum Features in EF5. Luckily, Resharper will Point out the Errors easily.
Please add automated support for EnumTypes and external referenced EnumTypes, thank you.
Coordinator
Jul 7, 2013 at 7:30 PM
@e36M3
I'm afraid I can't make the tool work the way you suggest, if you don't select te DTO's even if I analize the object graph I won't be sure you have the associated entities that you did not select, if add them and you don't have them that would be even more problems that the one you have today.
Coordinator
Jul 7, 2013 at 7:45 PM
Edited Jul 7, 2013 at 7:46 PM
@karmaedv
Thanks for using the tool.
1) For the folder creation suggestion, please, create a Work Item to track it. I don't think it is extremly necessary since the way you can do it today is very easy and doesn't take you precious time, it can also be considered out of scope.
2) This Work Item already suits your needs. Please, add additional related suggestions in the comments of it. No doubt this is a must.
3) Enum types are supported since v3.0, please, create a Work Item so I can work in your issue. Include all the details of the case. The current behavior is that if you use Enum types, those same Enum types will be the ones used by the DTOs, I'm very interested in knowing more about your problem. Thanks.
Jul 23, 2013 at 1:51 AM
Thank you for your efforts,

I would really appreciate following -
  1. Documentation
  2. Reference application using your framework
Which I am sure will help adoption of your tool :)
Coordinator
Jul 23, 2013 at 1:57 AM
Hi @khuzemaq8 and thanks a lot.
I totally agree with you and that's why I would like to know what do you think is missing from the docs?
Regarding a reference project using EntitiesToDTOs, I will work on that.
Thanks!
Jul 23, 2013 at 8:10 PM
Hi,

As a normal, documentation its fine. Just that some more clarification like in DTOs tab 5. Association - Key properties - if its mention the purpose of this option with example it would be excellent.

And the reference sample application, which shows how to use this DTO's with different layer scenario would much help. Though it may be out of scope but such a application will excellent tool for learning.

Thanks and best regards
Aug 27, 2013 at 4:12 PM
Hi,
Thank you for really nice tool.

I am wondering if it's possible to add automatic generation for Navigation properties (in Assemblers)? It should be possible to Assemble it if Navigation property is not null and has .Count() > 0 .
Something like:
        dto.ApplicationUserRoles = ApplicationUserRoleAssembler.ToDTOs(entity.ApplicationUserRoles);
Of course with gigantic warning that this should only be used with LazyLoadingEnabled = false or Armageddon will ensue. :)
Jan 26, 2015 at 1:41 PM
Hi Fabian,
First let me thank u for this great tool u r providing for us, it is amazing.
Second about new features i would like to be able to make Custom DataType mappings. For example in my ENTITIES i have "DateTime" properties that i would like to have their mapping in my DTOs as "String" properties. This feature is so important especially when we are using our DTOs in WCF, so that DateTime serialization will be done properly as JSON serialization of pure DateTime properties is done wrong.
What am currently doing is after i generate my DTOs am obliged to go to each genarated DTO and change DateTime properties to String ones. I think it would be a great feature to set our DataType mapping rules before generating DTOs.

Thanks alot again.
Coordinator
Jan 26, 2015 at 10:24 PM
Hi @Alino3481
Remember that DTOs generated are partial classes, you don't need to modify the generated classes, in fact, you shouldn't. You should extend the generated DTOs with partial classes as they are.
Partial Classes and Methods (C# Programming Guide)
Why use partial classes?
Jan 27, 2015 at 7:09 AM
Hi Fabian,
yes sure i know about partial classes but the matter will be that i will be obliged to make these custom mappings by hand while i want it in a automated way.
Am also using automapper to map my ENTITIES to DTOs without making any special custom mappings. Thats y i thought if it could be any possibility to choose my custom mapping on the DTOs level before generating them which will solve my prob without any custom writing.

10x