Dies könnte ein Entity Framework bezogene Frage, jedenfalls sein, hier geht:ADO.NET Data Services: Wie filtern Sie eine Entität basierend auf Fremdschlüsseln?
das folgende einfache Datenbank-Schema vor:
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)
)
Was ich will, ist es, Produkte auf einem Lieferanten filtern und eine Kategorie. Normalerweise würde ich nur eine Kategorie-ID und eine Lieferanten-ID liefern, aber da ich meine Datenbank durch EF bin aussetzt, Data Service erlaubt mich nicht, so etwas zu tun:
$filter=SupplierId eq 1 and CategoryId eq 2
Dies scheint ein ziemlich häufiges Szenario, also muss es möglich sein. Aber wie?