Entity Framework + AutoMapper ( Entity to DTO and DTO to Entity )

后端 未结 8 1243
逝去的感伤
逝去的感伤 2021-01-30 07:38

I\'ve got some problems using EF with AutoMapper. =/

for example :

I\'ve got 2 related entities ( Customers and Orders ) and they\'re DTO classes :

         


        
8条回答
  •  走了就别回头了
    2021-01-30 08:00

    As you can read here you need to do the following

    You can update entities with AutoMapper. Here's how: pass both the DTO and the entity object to AutoMapper's Map method. That's what this code does:

    custExisting = Mapper.Map(Of CustomerDTO,  Customer)(custDTO, custExisting)
    

    Also beware of mapping issues like the one described here

    These tips worked for me.

提交回复
热议问题