breeze错误:无法读取属性'toODataFragment'

时间:2014-07-14 22:37:11

标签: javascript asp.net-web-api breeze

我有以下BreezeController

[BreezeController]
public class BreezeController : ApiController
{
    readonly EFContextProvider<MyContext> _ContextProvider = new EFContextProvider<MyContext>();

    [HttpGet]
    public string Metadata()
    {
        return _ContextProvider.Metadata();
    }

    ....other controllers exposing model types....

    [HttpGet]
    public IQueryable<Size> Sizes()
    {
        return _ContextProvider.Context.Sizes;
    }
}

我使用此

从我的DataContext.js访问客户端
var getSizes = function (sizesObservable, modelId) {
        var query = entityQuery.from('Sizes').where('ID', '==', modelId)
            .orderBy('sortOrder').orderBy('size').orderBy('enteredDate');

        return manager.executeQuery(query)
            .then(querySucceeded)
            .fail(queryFailed);

        function querySucceeded(data) {
            if (sizesObservable) {
                var intialValues = { size: ' Select a Size', sizeID: breeze.core.getUuid(), modelID: modelId };
                createNullo(entityNames.size, 'Size', intialValues);
                sizesObservable(data.results);
            }
            log('Retrieved [Sizes] from remote data source', data, false);
        }
    };

所有这一切都很好。我想添加另一个路由到我的控制器,在服务器上完成一些专门的过滤。

[HttpGet]
public IQueryable<Size> GetUniqueSizes()
{
    return //custom filtering logic here.
}

在我的DataContext.js中使用以下javascript

var getUniqueSizes = function (sizesObservable, modelId) {
        var query = entityQuery.from('GetUniqueSizes').where('modelID', '==', modelId).where('Approved', '==', 'True')
            .orderBy('sortOrder').orderBy('size').orderBy('enteredDate');

        return manager.executeQuery(query)
            .then(querySucceeded);

        function querySucceeded(data) {
            if (sizesObservable) {
                var intialValues = { size: ' Select a Size', sizeID: breeze.core.getUuid(), modelID: modelId };
                createNullo(entityNames.size, 'Size', intialValues);
                sizesObservable(data.results);
            }
            log('Retrieved [Sizes] from remote data source', data, false);
        }
    };

但是当我这样做时,我在客户端上收到以下错误

TypeError: Cannot read property 'toODataFragment' …localhost:63144/scripts/breeze.debug.js:12728:23)

为什么这条路线不起作用?

1 个答案:

答案 0 :(得分:0)

尝试将多个orderBy语句更改为multiple property sort

.orderBy('sortOrder,size,enteredDate')
同样,如果你combine the where clauses,你可能会有更好的运气。