WebApi Controller hat im Entity Framework 5- und MVC 4-Projekt einen Wert zurückgegeben

Ich arbeite an einem Webapi, EF5, Windsor Castle in einem MVC 4-Projekt und habe eine Frage ... Soll ich das Entity (oder DTO) in der Get-Methode zurückgeben oder soll ich eine HttpResponseMessage zurückgeben? Was ist die bessere und üblichere Vorgehensweise?

Also, ist es das?

[System.Web.Http.HttpGet]
public HttpResponseMessage GetById(long id)
{
    var branch = Uow.Branches.GetById(id);
    if (branch != null)
    {
        Request.CreateResponse(HttpStatusCode.OK, branch);
    }

    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}

Oder dieses?

[System.Web.Http.HttpGet]
public Branch GetById(long id)
{
    var branch = Uow.Branches.GetById(id);
    if (branch != null) return branch ;
    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage