Asp.net web api EntitySetController generate 501中的自定义操作未实现 具有多对多关系的域对象: 要求

Asp.net web api EntitySetController generate 501中的自定义操作未实现 具有多对多关系的域对象: 要求,asp.net-web-api,odata,breeze,Asp.net Web Api,Odata,Breeze,/odata/Customers/GetByTag?$orderby=CompanyName&$expand=Tags&$select=Id、CompanyName、Phone、Tags/Id、Tags/Name&tagName=#5 问题 我做错了什么?为什么会出现错误501 在我的班级里,我是WebApiConfig。我需要此代码启用查询支持?为什么需要启用它?Breeze还不支持很多关系。作为解决方法,您可以使用两个1-many关系。在这个话题上有一个用户的声音问题;请投赞成票 publi

/odata/Customers/GetByTag?$orderby=CompanyName&$expand=Tags&$select=Id、CompanyName、Phone、Tags/Id、Tags/Name&tagName=#5

问题 我做错了什么?为什么会出现错误501


在我的班级里,我是WebApiConfig。我需要此代码
启用查询支持
?为什么需要启用它?

Breeze还不支持很多关系。作为解决方法,您可以使用两个1-many关系。在这个话题上有一个用户的声音问题;请投赞成票

public class Customer 
{
    public int Id { get; set; }
    public string CompanyName { get; set; }
    public string Phone { get; set; }
    public virtual ICollection<Tag> Tags { get; set; }
}

public class Tag
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<Customer> Customers { get; set; }
}
public class CustomersController : EntitySetController<Customer, int>
{
    // .. omited

    [HttpGet]
    public IQueryable<Customer> GetByTag([FromODataUri] string tagName)
    {
        tagName = tagName.Replace("#", "");
        return _Context.Customers.Where(p => p.Tags.Any(t => t.Name.Contains(tagName)));
    }
}
public static class BreezeWebApiConfig
{
    public static void RegisterBreezePreStart()
    {
        GlobalConfiguration.Configuration.Routes.MapHttpRoute(
            name: "BreezeApi",
            routeTemplate: "api/{controller}/{action}"
        );
    }
}

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.Routes.MapODataRoute("odata", "odata", GetEdmModel());
        config.EnableQuerySupport();
        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }

    public static IEdmModel GetEdmModel()
    {
        ODataModelBuilder builder = new ODataConventionModelBuilder();

        builder.EntitySet<Customer>("Customers");
        var customersByTagAction = builder.Entity<Customer>().Collection.Action("GetByTag");
        customersByTagAction.Parameter<string>("tagName");
        customersByTagAction.ReturnsCollectionFromEntitySet<Customer>("Customers");

        builder.EntitySet<Tag>("Tags");
        builder.Namespace = "WebAPIODataWithBreezeConsumer.Models";
        return builder.GetEdmModel();
    }
}