DTO -> Entity saveChanges issue

Apr 26, 2013 at 11:26 AM
Edited Apr 26, 2013 at 11:28 AM
Hi ffernandez,

I've created a DTO named SlideDTO. This DTO has a one to many relation with Groups.

After I filled SlideDTO with the needed properties and Groups I convert it to an entity object using
var entitySlide = Context.GetEntitytype<SlideDTO, Slide>(mySlideDTO);
So far everything went ok however after saving I see the SaveChanges action added new groups in the database (this is because the entity state of each group in the Groups EntityCollection is 'Added'). This is happening for all one-to-many associations.

How to prevent this? I don't want to create extra groups in my database.

Regards,

Marcel
Coordinator
Jun 28, 2013 at 1:04 AM
Hi Marcel.
Sorry for the too late response, been busy with other projects.
Could you not add the Groups to SlideDTO? I imagine you can't so is there any chance you set the EntityState to every Group of the SlideDTO before calling SaveChanges?
Thanks!
Marked as answer by ffernandez on 12/30/2013 at 6:58 PM