EF가 실행중인 모든 쿼리에 보편적으로 where 절을 추가하는 방법이 있습니까? 내가 예를EF 6 - Inject where clause
0
A
답변
0
(QueryTranslator 인터페이스를 구현없이) 가장 간단한 방법은 "== entity.Active 사실"모든 쿼리가 실행하고자하면이
public static IQyertable<YourEntity> OnlyActiveEntities(this YourDbContext context, Action<DbSet<YourEntity>> setConfigurator = null)
{
var dbSet = context.Set<YourEntity>();
setConfigurator?.Invoke(dbSet);
return context.Set<YourEntity>().AsQueriable().Where(entity => entity.Active == true);
}
1
일부 타사처럼 상황에 대한 확장 메서드를 만드는 것입니다 Entity Framework Filter Library List
면책 조항 : 라이브러리는 필터링 쿼리를 허용 EF + 검색어 : 내가 프로젝트 Entity Framework Plus
위키의 소유자 해요 필터
이 기능은 사용자가 찾고있는 기능입니다. 모든 쿼리를 필터링하기위한 전역 필터를 추가 할 수 있습니다.
예 :
// using Z.EntityFramework.Plus; // Don't forget to include this.
QueryFilterManager.Filter<ISoftDelete>(q => q.Where(x => x.IsActive));
관련 문제
- 1. C# where where clause fail
- 2. where exists clause sql
- 3. SQL 요청? Where clause
- 4. where timezones with clause
- 5. SQL 2 where clause
- 6. Dynamicallly Building Linq "where"clause
- 7. where clause SQL in JSP
- 8. SQL Where Clause Again View
- 9. EF 6 EF 코어
- 10. CLAUSE
- 11. CLAUSE
- 12. Ef 6 Linq의 RemoveRange
- 13. Coq의 예약 표기에 대한 여러 Where-clause?
- 14. SpringData MongoRepository Count와 Where clause 조합
- 15. Sql Multiple Where Where on Clause on 같은 필드에
- 16. 동적 Where Where Using Clause Using MDX Query
- 17. EF 6 오작동 엔티티
- 18. EF 6 찾기 및 포함
- 19. EF 6 및 ListView SelectMethod
- 20. 구현하는 방법을 거래/EF 6+
- 21. EF 6 성능 같은 테이블
- 22. 다중도 및 EF 문제 6
- 23. EF 6 자동으로 행 제한 추가
- 24. 효과적으로 GROUP BY 후에 "WHERE CLAUSE"가있는 SQL 쿼리
- 25. PHP - 배열의 알 수없는 열 Where clause 오류
- 26. MySQL - WHERE IN CLAUSE 정규식이 전화 번호와 일치하도록
- 27. 오류 "java.util.Date에서"매개 변수를 취하지 않습니다. "Squeryl 's where"clause "
- 28. If-statement 또는 case with FQL where-clause
- 29. EntityState.Modified를 사용하여 EF 6 DbContex를 업데이트하지 못했습니다.
- 30. in-clause 범위 지정