title: Web API, OData Passing in multiple parameters in GET operation
body: <p>Hoping someone can hepl with an issue I've been having.
  I've created a Web API that fetches records from the a database.
  I have the following functions in place which work ok:</p>
  
  <p><strong>localhost:8080/api/Budgets</strong> -- Returns all Budgets</p>
  
  <p><strong>localhost:8080/api/Budgets(799)</strong> -- Returns all for contract 799</p>
  
  <p>What I'm looking for is to be able to pass in two parameters to allow me to do calulations on the records retrieved so something like:</p>
  
  <p><strong>localhost:8080/api/Budgets(799)/215</strong> -- Where 799 is the contract Number and 215 is a material number.</p>
  
  <p>This will allow me to return a dataset of only materials for that budget that I can then do calculations on. There is only one SQL table for this which contains both the contract number and material number as well as a load of other figures.</p>
  
  <p>Here's what I have so far but it doesnt seem to be working:</p>
  
  <pre><code>    public IHttpActionResult Get()
      {
          return Ok(context.Budgets);
      }
  
      public IHttpActionResult Get([FromODataUri] int key)
      {
          var budgets = context.Budgets.FirstOrDefault(p =&gt; p.ProjectNo == key);
          if (budgets == null)
          {
              return NotFound();
          }
          return Ok(budgets);
      }
  
  [ODataRoute("GetMaterialUsage(ProjectId={ProjectId},ResourceCode={ResourceCode})")]
          public IHttpActionResult GetMaterialUsage([FromODataUri] int ProjectId, [FromODataUri] string ResourceCode)
          {
              var budgets = context.Budgets.FirstOrDefault(p =&gt; p.ProjectNo == ProjectId &amp;&amp; p.ResourceCode == ResourceCode);
              if (budgets == null)
              {
                  return NotFound();
              }
              return Ok(budgets);
          }
  </code></pre>
  
  <p>WebApiConfig:</p>
  
  <pre><code>            ODataModelBuilder builder = new ODataConventionModelBuilder();
  
          // Web API configuration and services
          builder.EntitySet&lt;BudgetTypes&gt;("BudgetTypes");
          builder.EntitySet&lt;Budgets&gt;("Budgets");
          var function = builder.Function("GetMaterialUsage");
          function.Parameter&lt;int&gt;("ProjectId");
          function.Parameter&lt;string&gt;("ResourceCode");
          function.ReturnsCollectionFromEntitySet&lt;Budgets&gt;("Budgets");
  
  
          // Web API routes
          config.MapHttpAttributeRoutes();
  
          config.MapODataServiceRoute(
              routeName: "ODataRoute",
              routePrefix: "api",
              model: builder.GetEdmModel()
          );
  </code></pre>
  
  <p>Can anyone shine some light on how this can be done?
  I just want to pass 2 parameters to a function from the url.</p>
  
  <p>At the moment the following links return 404:
  localhost:8080/api/Budgets(752,230)
  localhost:8080/api/Budgets(ProjectNo=752,ResourceCode=230)</p>