2009-04-22 4 views
1

이 어쨌든, 여기 간다하는 엔티티 프레임 워크와 관련된 질문을 할 수 있습니다ADO.NET Data Services : 외래 키를 기반으로 엔터티를 필터링하는 방법?

은 다음과 같은 간단한 데이터베이스 스키마를 고려

CREATE TABLE Supplier(
    SupplierId int identity(1,1) not null primary key, 
    DisplayName nvarchar(50) 
) 

CREATE TABLE Category(
    CategoryId int identity(1,1) not null primary key, 
    DisplayName nvarchar(50) 
) 

CREATE TABLE Product(
    ProductId int identity(1,1) not null primary key, 
    SupplierId int references Supplier.SupplierId, 
    CategoryId int references Category.CategoryId, 
    DisplayName nvarchar(50) 
) 

는 내가 원하는 것은 공급 업체 및 카테고리를 기반으로 제품을 필터링하는 것입니다. 일반적으로 그냥 범주 ID와 공급 업체 ID를 제공 할 것입니다,하지만 난 EF를 통해 내 데이터베이스를 노출하고 있기 때문에, 데이터 서비스가 나에게 이런 일을 수행하는 것을 허용하지 않습니다 :

$filter=SupplierId eq 1 and CategoryId eq 2 

이 꽤 일반적인 시나리오처럼 보인다을, 그래서 가능해야합니다. 그러나 어떻게?

$filter=Product/Supplier/SupplierID eq 1 and Products/Category/CategoryID eq 1 

감사합니다 :

답변

2

그것은이 수행하는 방법을 여기에, 꽤 쉽게 밝혀졌습니다.

관련 문제