I have a class used by Entity Framwork, called EFApplication.
Following this link, i want to add OData query option to my Web Api controller.
However, i don't want to use EFApplication class as the query parameters.
I want to use another class used just for the OData querying (ODataApplication)
Is this possible?
One of the reasons i want to use a different class is because OData doesn't support DateTime properties, and this means that i need to change it to DateTimeOffset, which i cannot do it (without breaking many other things)
// class mapped to Entity Frameowrk / Database
public class EFApplication
{
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
public virtual DateTime DateCreated { get; set; }
}
// class used for OData querying only
public class ODataApplication
{
public Guid Id { get; set; }
public string Name { get; set; }
}
public class ApplicationsController : ApiController
{
[EnableQuery]
public IQueryable<EFApplication> Get(ODataQueryOptions<ODataApplication> options)
{
// how to apply ODataQueryOptions<ODataApplication> query on top of EFApplication
return result; // IEnumerable<EFApplication>
}
}
DateTimefield. Then you should be able to use it OData - Sergey Litvinov