0

我们正在构建一个基于 .NET 的 REST API,它将被我们的单页 JavaScript 应用程序和未来可能的其他消费者使用。该应用程序将有许多显示数据的网格,并允许用户应用自定义过滤器和排序。诸如等于、包含、大于、小于、开始于等。

是否有一种可接受的方法在 URL 方案中实现这一点?尤其是不同的运营商。我不认为我将过滤器视为一流的资源,我可能想使用查询参数来表达过滤/排序。

看起来 OData 为这样的事情提供了解决方案,但总的来说,它似乎是一种重量级的方法,我担心它的接受度。是否有更轻、更受欢迎的替代品?

4

1 回答 1

1

Because you are considering several operations on your data: filter, sorting, etc I would say expose IQueryable on your endpoints and go with OData.

I would start here.

Please note that enabling OData on your API doesn't mean you are opening your data completely, you can always enable certain operations only, etc.

Check here to have a better idea on how to protect your API exposing OData.

I haven't tried any other alternative, but I guess you can always combine your routes and actions to get the functionality you need: top, filter, sorting, etc.

于 2013-04-26T15:05:59.833 回答