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? The main problem is that your 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 ()); }}
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
Post a Comment