Entity FrameWork 365-day series Source code research (1)

Source: Internet
Author: User

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)

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.