1

无论如何,这可能是与实体框架相关的问题:

考虑以下简单的数据库模式:

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

这似乎是一个很常见的场景,所以它一定是可能的。但是怎么做?

4

1 回答 1

2

事实证明这很容易,这是如何完成的:

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

问候。

于 2009-04-22T10:38:13.007 回答