【发布时间】:2013-10-05 05:49:50
【问题描述】:
我在客户端使用以下查询:
var query = breeze.EntityQuery.from("AllCustomers").where("CustomerId,"==",criteriaValue);
return this.manager.executeQuery(query)
这会产生以下网址:
/breeze/myAPI/AllCustomers?$filter=CustomerId%20eq%2012
我注意到在数据库中没有执行过滤(数据库执行的SQL中没有WHERE语句)。我怀疑,原因是Breeze.WebApi.QueryHelper.WrapResult,它调用Enumerable.ToList。后者将 IQueriable 转换为列表,在默认情况下 Microsoft OData 实现过滤 if 之前强制执行查询:
// if a select or expand was encountered we need to
// execute the DbQueries here, so that any exceptions thrown can be properly returned.
// if we wait to have the query executed within the serializer, some exceptions will not
// serialize properly.
queryResult = Enumerable.ToList((dynamic)queryResult);
queryResult = PostExecuteQuery((IEnumerable)queryResult);
这是 Breeze 中的错误还是我做错了什么?
我正在为实体框架使用 Oracle ODP.NET 提供程序。
更新:我正在使用 WebAPI 和控制器方法非常简单:
[BreezeController]
public class MyController : ApiController
{
[HttpGet]
public IQueryable<Customer> AllCustomers()
{
return _contextProvider.Context.Customers;
}
【问题讨论】:
标签: entity-framework asp.net-web-api odata breeze