It doesn't look like there's any built in function for getting the day of week using a function based on the documentation here:
http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html
What I want is a Web Api 2.2 OData V4 implementation that can service a url request like this:
/meeting?$filter=dayofweek(StartDate) eq 'Wednesday'
or something similar. But it seems like a pipe dream at this moment. Can someone show how this could be done? Would it have to be done using something like this?
builder.EntityType<Meeting>().Collection
.Function("DayOfWeek")
.Returns<IEnumerable<Meeting>>();
then
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.OData;
namespace Test.Controllers
{
public class MeetingsController : ODataController
{
private EntityContext db = new EntityContext();
[EnableQuery]
public IQueryable<Meeting> GetMeetings()
{
return db.Meetings;
}
[HttpGet]
public IHttpActionResult DayOfWeek(DateTime dayofweek)
{
//calculate day of week and return string
}
}
}