question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Map properties to existing object

See original GitHub issue

Is it possible to map properties to an existing object?

For an update operation, i receive a DTO and need to map its properties to a tracked entity from Entity Framework

Sample snippet:

Shop tracked = WriteContext.Shops.Single(s => s.Guid == shopDTO.guid);
tracked.Name    = shopDTO.Name;
tracked.Vendor  = shopDTO.Vendor;
 ... 
// Todo: map properties in tinymapper
WriteContext.SaveChanges();

It is important to update the properties in the tracked object, otherwise it will not get written to the database.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
buxelcommented, Dec 12, 2017

Ohhh, i missed that one. Thank you!

0reactions
GSerjocommented, Dec 12, 2017

Yes, try to use this method.

public static TTarget Map<TSource, TTarget>(TSource source, TTarget target = default(TTarget))

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automapper: Update property values without creating a ...
I'm seeing that mapping null into an object returns null; whereas in 2.2.1, mapping null into an existing object returned the existing object....
Read more >
Object To Object Mapping | Documentation Center | ABP.IO
ABP Framework provides a mapping definition extension to properly map extra properties of two objects.
Read more >
Mapping to existing object of same type returns the source ...
Ok, so to use map to auto-assign same properties on destination object of type A from source type A, I can create a...
Read more >
Understanding Map and Set Objects in JavaScript
In this article, you will go over the Map and Set objects, what makes them similar or different to Objects and Arrays, the...
Read more >
Automapper - Update object ORM
am trying to update an object using telerik openaccess orm and automapper, it works for adding the object to scope but not update....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found