1

I have a RESTier Website using the latest version. All my entities and views I created from the database with EF 6 work fine, but I cannot seem to get the stored procedures I brought in to work. As the documentation is a little sparse I'm not sure if I need to implement anything beyond to basic startup of the service.

When sending this URI via Postman I get a 404 error not found: http://192.168.1.20:60666/api/MIC_REST/up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_TEST(jobID=252, fmNumber= 98, workAreas='A13,D12,A3,A9,A7,A10')

I basically have stock setup of service below. Any help in whether it might be the URI or the setup would be greatly appreciated.

WebApiConfig:

public static class WebApiConfig
{
    public async static void Register(HttpConfiguration config)
    {
        config.EnableSystemDiagnosticsTracing();
        config.Filter().Expand().Select().OrderBy().MaxTop(1000).Count();
        await config.MapRestierRoute<EntityFrameworkApi<MICdB>>(
            "MIC_REST", "api/MIC_REST", new Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler(GlobalConfiguration.DefaultServer));
    }
}

public virtual ObjectResult<up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_Result_TEST> up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_TEST( Nullable<int> jobID, Nullable<int> fmNumber, string workAreas)
{
    var jobIDParameter = jobID.HasValue ?
            new ObjectParameter("JobID", jobID) :
            new ObjectParameter("JobID", typeof(int));

    var fmNumberParameter = fmNumber.HasValue ?
            new ObjectParameter("FmNumber", fmNumber) :
            new ObjectParameter("FmNumber", typeof(int));

    var workAreasParameter = workAreas != null ?
            new ObjectParameter("WorkAreas", workAreas) :
            new ObjectParameter("WorkAreas", typeof(string));

    return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_Result_TEST>("up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_TEST",  jobIDParameter, fmNumberParameter, workAreasParameter);
}

public partial class up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_Result_TEST
{
    public string BomAssemShipMark { get; set; }
    public string CurrentLocation { get; set; }
    public int Quantity { get; set; }
    public string PlPiecemark { get; set; }
    public string MatSizeText { get; set; }
    public string LengthText { get; set; }
    public string GradeDescription { get; set; }
    public string PlPiecemarkPrefix { get; set; }
    public int PlPiecemarkSuffix { get; set; }
    public string PlCodes { get; set; }
    public string PlPremark { get; set; }
    public Nullable<int> FmNumber { get; set; }
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
patrickL
  • 23
  • 4
  • Note the 404 indicates there is no handler so I believe my issue is to setup a controller handler for the code created by ResTier/odata 4. So I'm looking for an example to hook up the virual ObjectResult methods. – patrickL Feb 07 '17 at 00:01

1 Answers1

0

After banging my head on trying to get an ODataController to work, I have giving up and resorted to using an Apicontroller, which ended up being very simple to implement. With an ODataController, I could never get a URL to work or if I tried to add an oDataRoute, an error always resulted. It seems absurd that with all the fairly useless examples posted using ResTier the one real world example that one would expect (a stored procedure that returns a list of non-entity data for UI view purposes) seems non-existent. ResTier seems to work great for EntitySets but this mess I found myself in makes me question it (or Odata not sure where the fault is). Oh well, below gets the data...now to find a compress to fix the welt on my forehead....

   [System.Web.Http.RoutePrefix("spapi/MIC_REST")]
public class SPController :ApiController
{
    private MICdB db = new MICdB();

    [System.Web.Http.Route("part/{jobID:int}/{fmNumber:int}/{workAreas}")]
   // [EnableQuery]
     public List<up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_Result> GetPartsLists([FromODataUri]int jobID, [FromODataUri]int fmNumber, [FromODataUri]string workAreas)
    {
        return db.up_BomAssemParts_s_ByJobID_FmNumber_WorkArea_TEST(jobID, fmNumber, workAreas).ToList();
    }
}
patrickL
  • 23
  • 4