public class YourTableController : ODataController
{
/// <summary>
/// The database
/// </summary>
private YourDatabaseEntities db = new YourDatabaseEntities();
/// <summary>
/// Adds Accept header for Tableau which requires XML data but doesn't send a header requesting it
/// </summary>
protected void FTLP()
{
try
{
Request.Headers.Remove("Accept");
}
catch { }
try
{
Request.Headers.Add("Accept", "application/atom+xml");
}
catch { }
}
// GET: odata/YourTable
/// <summary>
/// Gets the Your Table.
/// </summary>
/// <returns>IQueryable<YourTable>.</returns>
[EnableQuery]
public IQueryable<YourTable> GetYourTable()
{
FTLP();//Add this to Fix Tableau XML requirement
return db.YourTable;
}
// GET: odata/YourTable(5)
/// <summary>
/// Gets the YourTable.
/// </summary>
/// <param name="key">The key.</param>
/// <returns>SingleResult<YourTable>.</returns>
[EnableQuery]
public SingleResult<YourTable> GetYourTable([FromODataUri] DateTime key)
{
FTLP();//Add this to Fix Tableau XML requirement
return SingleResult.Create(db.YourTable.Where(YourTable => YourTable.Date == key));
}