c# - Inherit multiple base classes with the same inherited method-name -


Note: I am fairly new to the C # NET MVC and entity framework, and I am working on an existing project. In this project I have the following category:

  Public category MyDbContext: DbContext, IMyDbContext {Public MyDbContext (): Base ("name = SQLAzureConnection") {} ... // Some IDbSet properties ... // some methods}  

and the following interface:

  Public Interface IMyDbContext {... // Some properties ... // something Revoke methods (); }  

I use one of my methods:

 using  (using db = mvcApplication.dbContext (IMyDbContext)) { // usingDB} / code>  

( MvcApplication.dbContext ()) to be a representative (funk), which is instantaneously in my MvcApplication` like this:

  Public class MvcApplication: System.Web.HttpApplication {// to create a new IMyDbContext example public static Func & lt; IMyDbContext & gt; dbContext; public static MyDbContext dbContextInit () {new MyDbContext () ;} ... // Some other fields protected void Applica Tion_Start () {... dbContext = dbContextInit ();}}  

I have this representative for short-term DbContext and my unit is capable of using it in the test.)

Since the object should be a disposable , I have modified my interface in the following:

  Public interface IMIDBcontent: id isposable {.. .} Some properties ... // some methods (without); }  

Everything works, except I get the following warning:

  'MyNamespace.Model.IMyDbContext.Dispose ()' inherited member 'Hides System.IDisposable .Dispose ()'. If you intended to hide, then use the new keyword.  

So that means I should use it: New zero (); instead of zero () ? The only reason I created it is that it can be used by IDisposable so I can use it in . So I think the new -keyword is, so it will use DbContext.Dispose () ? Or am I doing something wrong?

I have also read that I can use using by using , so I use DB while using . Dispos () in its own end-case . Nevertheless, I want to inherit myself from IDisposable instead of that option.

To get rid of your code, is in your equation because you first If you are receiving it from IDisposable , then just change your interface to:

  Public Interface IMyDbContext: IDisposable {... // some properties}  

That's because you are already making your IMyDbContext disposable already IDisposable you do not need to explicitly add again . The compilation is warning you that you are doing a strange way without clearly telling users of two dissection why

summary: just delete it and you Are golden!


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -