Add filter to all query entity framework

前端 未结 4 1566
孤街浪徒
孤街浪徒 2020-12-18 11:07

I want add CompanyID filter to my all entity framework request.Because each user must see just their records.I dont want add filter (x=>x.CompanyID == cID) all methods in bu

4条回答
  •  感情败类
    2020-12-18 11:56

    everything you suggest does not work for the following scenario: HasQueryFilter power, but per each HTTP request. ApplyGlobalFilters / OnModelCreating applied once for model creation. But if you reload the page with different request parameters - they won't be taken into account to filter out DbSet. If you add the filter to GetAll call - another call 'Include'-ing the entity won't have this filter. We need real global mechanism to filter out DbSets by specific condition - which may change per each request (page refresh).

提交回复
热议问题