Web API
응용 프로그램에 Get 메서드에서 OData
을 사용하면 일관성없는 결과가 나타납니다. OData
필터가 없으면 결과는 양호합니다. OData를 사용할 때 직렬화가 다르게 처리됩니까?나는 이것을 올바르게하고 있나? 하나로, OData으로OData 및 Entity Framework가있는 웹 API
:
내가 $ 심판 항목이 무엇인지 이해하지, 왜 랜덤이며, OData
를 사용하지 않을 때는 왜 그들을 얻을하지 않습니다?
public HttpResponseMessage Get(System.Web.Http.OData.Query.ODataQueryOptions<Employee> options)
{
HttpResponseMessage response;
var employees = options.ApplyTo(_unitOfWork.EmployeeRepository.Get());
if (employees == null)
{
response = new HttpResponseMessage(HttpStatusCode.NotFound);
}
else
{
response = Request.CreateResponse(HttpStatusCode.OK, employees);
response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now.AddSeconds(300));
}
return response;
}
여기에 직렬화되는 클래스이다 : 여기
는 Web API
방법이다
public class Employee
{
[Key]
public string WinId { get; set; }
public string XML { get; set; }
public int EffectiveYear { get; set; }
public int FileKeeperGroupId { get; set; }
}
편집 8/15
여기 내 WebApiConfig의
,321 0
OData 사용의 의미를 명확히하지 않습니까? ApiController 대신 ODataController를 사용 하시겠습니까? OData를 사용하는 코드도 표시 할 수 있습니까? – QianLi