Entity Framework 4.1 - Override Entity (DBSet) with Filter

后端 未结 5 1675
余生分开走
余生分开走 2021-02-06 03:38

I\'m trying to do something which should be relatively easy, but i just dont know how to construct it.

I have a Generated Entity which I\'d like to override by adding a

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 04:19

    I know this is super old, but another simple and elegant way, without changing any existing names, is using the new keyword to hide the original member, like this:

    public new IQueryable Assignees 
    {
        get
        {
            return base.Assignees.Where(z => z.IsActive == true);
        }
    }
    

    Just wanted to share for any future visitors, hope it helps!

提交回复
热议问题