c# - NullReferenceException in Repository Pattern -


I am using the repository pattern and tap my _dataContext object in my repository. What can I do to make it empty? Private BlogDataContext _dataContext; Private Readonly IDbSet & lt; T & gt; _dbset; Private string [] _path; Public Repositories (IDbsfairware database pharmacy) {DataContext.Database.Log = console.light; DatabaseFactory = databaseFactory; _dbset = DataContext.Set & lt; T & gt; (); } Protected IDatabaseFactory DatabaseFactory {get; Private set; } Get Protected BlogDataContext DataContext {get_dataContext} (_dataContext = DatabaseFactory.Get ()); }}

The main problem is that your DatabaseFactory property There is a private setter, so you can not specify anything directly to it. To create a personal IDatabaseFactory field, assign constructor parameter databaseFactory to this field and return it to your DatabaseFactory Property or DatabaseFactory make the property sector method public.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -