我确实尝试过使用带odata v4的angular 2 kendo网格进行服务器端过滤,但显示不支持'contains'关键字。新版本使用“substringof”而不是“contains”,我该如何解决此问题

最佳答案

安装Odata V4并配置WebApiConfig.cs

 ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
                var customer = builder.EntitySet<CustomerModel>("CustomerSearch");

                config.Routes.MapODataServiceRoute(
                  routeName: "odata",
                  routePrefix: "odata",
                  model: builder.GetEdmModel());

“CustomerModel”是我要返回的模型
“CustomerSearch” Controller 名称

Odata Controller
 [EnableQuery]
    public class CustomerSearchController : ODataController
    {

        [EnableQuery]
        public IQueryable<CustomerModel> Get()
        {
            CustomerModelResponse list = new CustomerModelResponse();
            try
            {
                list = CustomerBL.GetCustomer(0);
            }
            catch (Exception)
            {

                throw;
            }
            return list.CustomerList.AsQueryable();
        }

    }

10-01 23:09