The following is how i do it for a t-sql command. The same idea works for views (though we define those views in our model). Works great. Of course, no updating or adding, but that is to be expected.
internal class RvRDetail
{
public string DistrictName { get; set; }
public string EmployeeName { get; set; }
public string SiteName { get; set; }
public System.DateTime CalendarDate { get; set; }
public string RevenueCategoryName { get; set; }
public decimal TotalRepayment { get; set; }
public decimal TotalRevenue { get; set; }
}
[BreezeController]
public class SeasonlessRvRController : BreezeAbstractApiController
{
// GET: breeze/SeasonlessRvR/RvRData
[HttpGet]
public object RvRData(string districtList="", string showAllPeriods="0")
{
var returnData = _dbContextProvider.Context.Database
.SqlQuery<RvRDetail>("SELECT * from dbo.udf_SeasonlessRvR(@DistrictList, @ShowAllPeriods)",
new SqlParameter("@DistrictList", districtList),
new SqlParameter("@ShowAllPeriods", showAllPeriods))
.ToList();
return returnData;
}
}