Fixed Assemblers ToDTO assignment code generation for navigation properties.

Mar 14, 2013 at 9:13 PM
Hi, just noticed that 3.1 is out and I am not certain what "Fixed Assemblers ToDTO assignment code generation for navigation properties." means, I don't see anything different (other than ICollection vs. List) in my Assemblers. If you could elaborate on what you mean by this it would be great.

Thank you.
Coordinator
Mar 14, 2013 at 9:16 PM
Hi there.

Check this StackOverflow question, it will answer everything regarding this fix. I will update release details so everyone can see it.

Thanks!
Mar 14, 2013 at 9:38 PM
Was this only an issue for Association properties that were selected as "Key Properties"? Because I've been using Class Types and I don't think I've ever seen this behavior. I always assumed the mapping was for scalar properties only and it was up to me to map the underlying properties as required. Or could it be because I always have lazy loading off in the edmx?
Coordinator
Mar 14, 2013 at 9:39 PM
You are correct, this was only happening if you used DTOs Association by Key.
Mar 14, 2013 at 9:42 PM
Excellent, thanks for the prompt response. I've been scratching my head for a while trying to figure out what you meant :) I will be following up with another post soon with some suggestions that I noted after using your tool...

Thanks again.
Coordinator
Mar 14, 2013 at 11:16 PM
Suggestions are welcome!!

Thanks for using EntiiesToDTOs!
Jul 15, 2013 at 8:12 PM
I have entitiestodtos V3.2,

EF 5.0, Lazy Loading enabled
Using Association by Class Type,

I am still having problems with the "Navigation Properties" of Parent / Child Tables.

Has this been fixed in my current version (Am i doing something wrong) Or this is still to be implemented in next versions?
Coordinator
Jul 16, 2013 at 2:15 AM
Edited Jul 16, 2013 at 2:16 AM
Hi @emouawad

The bug reported at Stackoverflow was fixed before v3.2.

I don't exactly what's the behavior you are expecting so you can tell me in order to see if what your are experiencing is a bug or a desired behavior.

Just to give some light on the subject, when you map using .ToDTO(), .ToDTOs(), .ToEntity(), .ToEntities()... navigation properties are not mapped. It's up to the developer to map navigation properties.

E.G.:
var accounts = new List<AccountEntity>();
accounts.Add(new AccountEntity(accountName1));
accounts.Add(new AccountEntity(accountName2));

var entity = new ClientEntity(firstName, lastName, accounts);

ClientDTO dto = entity.ToDTO();
dto.Accounts = entity.Accounts.ToDTOs();
What's important to us here it's at the last line of code. Here we are including the AccountDTO's in the ClientDTO.Accounts collection because it is not mapped in the entity.ToDTO() method.

You can also use partial methods OnDTO and OnEntity to perform this and other desired tasks every time ToDTO/ToEntity is invoked.
Marked as answer by ffernandez on 12/30/2013 at 6:51 PM