-
Notifications
You must be signed in to change notification settings - Fork 22
Mapping Graphs
Leonardo Porro edited this page Dec 16, 2022
·
36 revisions
This library allows to map data directly into an entity graph and set the right state for each entity automatically.
The type of the data to be mapped can be the same entity, any other class or anonymous type with a similar structure or dynamic objects like a dictionary or json.
Entity graph consists of the main entity to be updated along a subset of its related entities.
User user = await _dbContext.MapAsync<User>(new User { Id = 1, Name = "user name" });
User user = await _dbContext.MapAsync<User>(new UserDTO { Id = 2, Name = "this User was mapped from a DTO" });
User user = await _dbContext.MapAsync<User>(new { Id = 3, Name = "this User was mapped from an Anonymous Type" });
User user = await _dbContext.MapAsync<User>(new Dictionary<string, object> { { "Id", 4 }, { "Name", "this User was mapped from a Dictionary" });