How can I pass an object (Entity) to an OData Action? I can pass simple types and ComplexType, but if try to pass an EntityType I get:
Invalid parameter type 'apitest.Models.Product'.
A non-binding parameter type must be either Primitive, Complex,
Collection of Primitive or a Collection of Complex.
Edit:
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Product>("Products");
modelBuilder.EntitySet<PurchaseOrder>("PurchaseOrders");
var addProduct = modelBuilder.Entity<PurchaseOrder>().Action("AddProduct");
addProduct.Parameter<Product>("product");
addProduct.ReturnsFromEntitySet<PurchaseOrder>("PurchaseOrders");
I've tried replacing addProduct.Parameter<Product>("product");
with:
var productConfig = modelBuilder.StructuralTypes.OfType<EntityTypeConfiguration>().Single(x => x.Name == "Product");
addProduct.SetBindingParameter("product", productConfig, false);
But I haven't been able to find any documentation on how to use SetBindingParameter. If I register Product as a ComplexType, the first code sample works, but then I'm not allowed to register it as Entity.