BaseRepository Question

Aug 29, 2011 at 8:38 AM


I was looking at the BaseRepository class and I was wondering why the following was present:

        protected virtual DbSet<TEntity> GetDbSet<TEntity>() where TEntity : class
            return this.Context.Set<TEntity>();
        protected virtual void SetEntityState(object entity, EntityState entityState)
            this.Context.Entry(entity).State = entityState;


James :-)

Aug 29, 2011 at 6:46 PM


The classes in the Repositories folder in the MileageStats.Data.SqlCe project contain logic to interact with SQL Server Compact Edition, through the use of Entity Framework. The BaseRepository class is a base class for the repositories, and so it contains two methods that represent operations that will be performed in the repository classes to interact with Entity Framework.

You can find information about the DbSet and entity state in the following resources:

I hope you find this helpful.

Guido Leandro Maliandi