AutoMapper.Collection.EFCore | EFCore support for AutoMapper.Collections | Code Editor library
kandi X-RAY | AutoMapper.Collection.EFCore Summary
kandi X-RAY | AutoMapper.Collection.EFCore Summary
Automapper.Collection.EntityFrameworkCore does that as well through extension method from of DbSet . Translate equality between dto and EF object to an expression of just the EF using the dto's values as constants. Note: This is done by converting the OrderDTO to Expression> and using that to find matching type in the database. You can also map objects to expressions as well. Persist doesn't call submit changes automatically.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AutoMapper.Collection.EFCore
AutoMapper.Collection.EFCore Key Features
AutoMapper.Collection.EFCore Examples and Code Snippets
var services = new ServiceCollection();
services
.AddEntityFrameworkInMemoryDatabase()
.AddDbContext();
services.AddAutoMapper((serviceProvider, automapper) =>
{
automapper.AddCollectionMappers();
automapper.UseEntityFrameworkCore
dbContext.Orders.Persist(mapper).InsertOrUpdate(newOrderDto);
dbContext.Orders.Persist(mapper).InsertOrUpdate(existingOrderDto);
dbContext.Orders.Persist(mapper).Remove(deletedOrderDto);
dbContext.SubmitChanges();
PM> Install-Package AutoMapper.Collection.EntityFrameworkCore
Community Discussions
Trending Discussions on AutoMapper.Collection.EFCore
QUESTION
ANSWER
Answered 2020-Oct-13 at 07:35I found the problem. I added this to map the collections to the AutoMapper configuration:
QUESTION
I try to use AutoMapper.Collection.EntityFrameworkCore to map my objects. All is working fine if I use the same DbContext all the time.
The problem is that there is no possibility to reject all cached objects in DbContext. Yes I did a search and found this post but it doesn't work. I don't realy understand the problem but I bet it is because I only detach the container object. There is no way without complex algorithms to traverse all objects to detach them all.
This is the currently working code (very simplyfied):
...ANSWER
Answered 2019-Nov-29 at 10:05I found a solution that seems to work. The steps are the following:
- Load:
- Create a
DbContext
instance - Load the DTO and map it to business logic instance
- Reject the
DbContext
instance
- Create a
- Modify the business logic instance (add/modify/remove children)
- Save:
- Create a
DbContext
instance - Load the DTO that corresponds to the business object by key into
DbSet
. The return value doesn't matter. We only need to know about this object. - Save the changed business logic instance using
InsertOrUpdate
.
- Create a
This performs a load operation that shouldn't be needed but I didn't find an other solution.
The simplyfied code is:
QUESTION
AutoMapper.Collection.EFCore was just published today on Nuget, and I am now trying to use.
I have set it up according to the Docs:
In startup.cs, in the ConfigureServices method:
...ANSWER
Answered 2018-Nov-21 at 18:55Renamed to UseEntityFrameworkCoreModel. You should report it so they change the message.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AutoMapper.Collection.EFCore
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page