2013-05-29 36 views
1

我想用類OfferFilter來處理請求提供路由屬性:服務棧 - 複雜請求類

public class OfferFilter 
{ 
    public int SortOrder { get; set; } 
    public int PageSize { get; set; } 
    public int PageNumber { get; set; } 
    public string SearchQuery { get; set; } 
    public bool ShowAllLanguages { get; set; } 
    public int? SearcherSectorId { get; set; } 
    public int? CountryId { get; set; } 
    public int? RegionId { get; set; } 
    public string City { get; set; } 
    public int? AskingPriceFrom { get; set; } 
    public int? AskingPriceTo { get; set; } 
    public bool AskingPriceSelected { get; set; } 
    public int? SalesRevenuesFrom { get; set; } 
    public int? SalesRevenuesTo { get; set; } 
    public bool SalesRevenuesSelected { get; set; } 
    public int? IncomeFrom { get; set; } 
    public int? IncomeTo { get; set; } 
    public bool IncomeSelected { get; set; } 
    public int? Age { get; set; } 
} 

我怎麼能做出一個路由屬性?使用POST會更容易,但它會是GET請求。正常的路線字符串將是巨大的,非常容易出錯。

回答

1

請參閱關於Routing的維基頁面。你只需要註冊的服務路徑信​​息,而你仍然可以使用任何屬性的查詢字符串,如:

[Route("/offers/search")] 
public class OfferFilter { ... } 

讓與您通話的任意組合上述服務,例如:

/offers/search?city=XXX 
/offers/search?city=XXX&Age=20 
etc.