Entity Framework 4.1 - Override Entity (DBSet) with Filter

后端 未结 5 1771
余生分开走
余生分开走 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条回答
  •  天命终不由人
    2021-02-06 04:11

    Try exposing DbSet and IQueryable with different names

    public partial class MyEntities: DbContext
    {
        public MyEntities()
            : base("name=MyEntities")
        {
        }
    
        public DbSet AssigneesSet { get; set; }
    
        public IQueryable Assignees 
        {
            get
            {
                return AssigneesSet.Where(z => z.IsActive == true);
            }
        }
    }
    

提交回复
热议问题