By Kmsfan-this series of articles only as their own reading notes, not included in the blog home page.
Summary of Knowledge points:
1.DBContext class
Properties in 2.Attribute (Notnull)
3.DbContext implementation of 2 interfaces: 1.IDisposeable 2.IDbContextService
Namespace Microsoft.Data.Entity.Commands
Let's take a look at something under this namespace, there's a Contexttool method
There is a Createcontext method inside.
Due to my own interest in dbcontext comparison, so I could not help but pressed the next F12, so I saw the following structure:
where DbContext implemented 2 interfaces, one is IDisposable, the other is idbcontextservices, I think, since the implementation of these 2 interfaces, then certainly implemented the 2 interface in the method it?!
Heart than action, hurriedly see what is inside.
IDisposable:
namespace system{//// Abstract:/ / defines a method for releasing allocated resources. Public Interface IDisposable {//// Summary: // perform application-defined tasks related to releasing or resetting unmanaged resources. void Dispose ();} }
Idbcontextservice
Using System;namespace microsoft.data.entity.infrastructure{public interface idbcontextservices { IServiceProvider scopedserviceprovider {get;}} }
Because I use VS2015, hey, new features, tell everyone a small secret, you can see where the reference to this interface oh.
So you can see the importance of this interface?! There are a lot of these things in EF, and that's probably where EF is really powerful. Let's go back to createcontext this way, there is a thing called attribute, I here is not NULL, is not empty.
That is, the parameters passed in are not empty (formal parameters). Let's take a look at this not null what is the divine?!
Internal sealed class Notnullattribute:attribute { }
Did you see that? It's actually a closed inner class, and there's nothing in it. Online I did not find the answer, in the end, omnipotent Google has a solution, hey. I will not translate, and later to translate.
Http://stackoverflow.com/questions/4619185/what-is-an-internal-sealed-class-in-c
Well, we'll be here today, and we'll continue to summarize tomorrow.
Entity FrameWork 365-day series Source code research (1)