Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i pass an object (Entity) as a parameter on WebApi Odata
    primarykey
    data
    text
    <p>i follow this link <a href="http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/odata-actions" rel="nofollow">Supporting OData Actions in ASP.NET Web API</a> And i want to pass my object/Entity as a parameter like this:</p> <pre><code>ActionConfiguration addNewPatient = builder.Entity&lt;Patient&gt;().Collection.Action("AddNewPatient"); addNewPatient.Parameter&lt;int&gt;("hospId"); addNewPatient.Parameter&lt;int&gt;("docId"); addNewPatient.Parameter&lt;Patient&gt;("patient"); addNewPatient.Returns&lt;bool&gt;(); </code></pre> <p>but i got this issue:</p> <pre><code>System.ArgumentException: Invalid parameter type 'Patient'. A non-binding parameter type must be either Primitive, Complex, Collection of Primitive or a Collection of Complex. Parameter name: parameterType </code></pre> <p>I tried to implement this</p> <pre><code> ActionConfiguration addNewPatient = builder.Entity&lt;Patient&gt;().Collection.Action("AddNewPatient"); addNewPatient.Parameter&lt;int&gt;("hospId"); addNewPatient.Parameter&lt;int&gt;("docId"); var patientConfig = builder.StructuralTypes.OfType&lt;EntityTypeConfiguration&gt;().Single(x =&gt; x.Name == "Patient"); addNewPatient.SetBindingParameter("patient", patientConfig, false); addNewPatient.Returns&lt;bool&gt;(); </code></pre> <p>but i can't call method POST ../odata/Patient/AddNewPatient anymore</p> <pre><code>&lt;FunctionImport Name="AddNewPatient" ReturnType="Edm.Boolean" IsBindable="true"&gt; &lt;Parameter Name="patient" Type="Patient"/&gt; &lt;Parameter Name="hospId" Type="Edm.Int32" Nullable="false"/&gt; &lt;Parameter Name="docId" Type="Edm.Int32" Nullable="false"/&gt; &lt;/FunctionImport&gt; </code></pre> <p>Please help me, i tried various way but still no luck. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload