Osharp3 experience: Integration of DbContextScope 1, 3

Source: Internet
Author: User

Osharp3 experience: Integration of DbContextScope 1, 3

Osharp3's transaction processing is controlled by skipping the savechangeing method, without DbContextScope expertise

DbContextScope Advantages and Disadvantages of dbcontext management this article does not discuss

Integration Process:

1. In. Data. Entity/Extensions/ServiceCollectionExtensions. cs

Inject 1 DbContextScopeFactory and IAmbientDbContextLocator,

And remove the IUnitOfWork injection,

It means that dbContext is completely handed over to DbContextScope for management.

Ii. Repository transformation <TEntity, TKey>

3. public IDbContextScopeFactory _ dbContextScopeFactory {get; set;} is injected into the application service layer ;}

Iv. Usage

5. Modify DbContextScope and Add DbContext Get (Type _ DbContextType );

The changes are as follows:

Https://github.com/shiningrise/DbContextScope/commit/8d48f584d0c1a159e2688f2dda5135356137d4b0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.