Inherits from DbSet<T> with the purposes to add property

Viewed 4802

Is there a way to inherits from DbSet? I want to add some new properties, like this:

public class PersonSet : DbSet<Person>
{
    public int MyProperty { get; set; }
}

But I don't know how to instantiate it in my DbContext

public partial MyContext : DbContext
{
    private PersonSet _personSet; 
    public PersonSet PersonSet
    {
        get 
        {
            _personSet = Set<Person>(); // Cast Error here
            _personSet.MyProperty = 10;
            return _personSet;
        }
    }
}

How can I achieve this?

4 Answers
Related