[FromBody]对象可以具有功能吗?

时间:2017-03-01 02:24:29

标签: c# asp.net asp.net-mvc visual-studio rest

我有一个接受该对象的控制器:

    /// <category>Location Operations</category>
    /// <name>Search by SearchObject</name>
    [Route("Location/Search", Name = "LocationSearch")]
    [HttpGet]
    public List<Entity> LocationSearch([FromBody] SearchObject searchObject)
    {
        var location = _locationService.Search(searchObject).ToList();
        return location;
    }

我已将SearchObject定义为:

public class SearchObject
{
    /// <summary>   Initializes a new instance of the Omnia360.ProductApi.Model.Locations.SearchObject class. </summary>
    public SearchObject()
    {
        this.SearchTerms = new List<SearchTerm>();
    }

    /// <summary>   Gets or sets the name of the entity. </summary>
    /// <value> The name of the entity. </value>
    public string EntityName { get; set; }

    /// <summary>   Gets or sets the search terms. </summary>
    /// <value> The search terms. </value>
    public IList<SearchTerm> SearchTerms { get; set; }
}

这是一个有效的定义,或者用作[FromBody]的对象是否需要只有{get;set;}且没有任何功能?

0 个答案:

没有答案