无论如何,这可能是与实体框架相关的问题:
考虑以下简单的数据库模式:
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
这似乎是一个很常见的场景,所以它一定是可能的。但是怎么做?