Last post Jul 28, 2016 10:34 AM by enendaveyboy
Jul 26, 2016 09:25 PM|enendaveyboy|LINK
I have a generic repository which uses the Identity Setup, and I can't find any tutorials or information, but current constructor is
public BaseRepository(IUnitOfWork unitOfWork)
if (unitOfWork == null)
throw new ArgumentNullException("unitOfWork");
_context = unitOfWork as ApplicationDbContext;
this._entities = _context.Set<T>();
But this doesn't give me access to LoadProperty, and I have two many includes which is causing problems, can anyone give me a little point in the right direction?
Jul 28, 2016 08:56 AM|Brando ZWZ|LINK
Can I access LoadProperty through ApplicationDbContext?
As far as I know, LoadProperty is a method which used in ObjectContext in System.Data.Entity.dll.
According to your code it seems that you are using IUnitOfWork as Context. Could you please explain more about ‘IUnitOfWork’ ?
If it is possible, please post some codes about how IUnitOfWork’ defined.
In most circumstances, when use Repository, we will pass a parameter which type is DBcontext or other object which is inherited it. Code as below:
public class Repository<T> where T : BaseEntity
private readonly EFDbContext context;
private IDbSet<T> entities;
string errorMessage = string.Empty;
public Repository(EFDbContext context)
this.context = context;
More details, you could refer to follow link:
Besides, if you want to implement generic repository and use it for unit of work, you could refer to follow link:
Jul 28, 2016 10:34 AM|enendaveyboy|LINK
I use the IUnit of Work to ensure all database changes are one istance (I think)
public interface IUnitOfWork : IDisposable
I use aufofac as an IOC
I started with the asp.net website one but then changed it to add different functions and work with an IOC, so I guess I am out of luck, but thanks for the help.