In the following example, the action "ExtendSupportDate" has a return type of Product which is actually an entity type. Currently the Edmmodel generates without an error. We should throw an indicating that if a user is returning an entity type, they should always associate with an EntitySet.
ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();
var products = modelBuilder.EntitySet<Product>("Products");
var productFamilies = modelBuilder.EntitySet<ProductFamily>("ProductFamilies");
var suppliers = modelBuilder.EntitySet<Supplier>("Suppliers");
var config = products.EntityType.Action("ExtendSupportDate");
config.Parameter<DateTime>("newDate");
config.Returns<Product>();
Metadata generated:
----------------------
<FunctionImport Name="ExtendSupportDate" ReturnType="ODataService.Models.Product" IsBindable="true">
<Parameter Name="bindingParameter" Type="ODataService.Models.Product"/>
<Parameter Name="newDate" Type="Edm.DateTime"/>
</FunctionImport>
This is a negative case and also there are comments on this API. Users could use api like ReturnsFromEntitySet or ReturnsCollectionFromEntitySet to avoid the problem here.
ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();
var products = modelBuilder.EntitySet<Product>("Products");
var productFamilies = modelBuilder.EntitySet<ProductFamily>("ProductFamilies");
var suppliers = modelBuilder.EntitySet<Supplier>("Suppliers");
var config = products.EntityType.Action("ExtendSupportDate");
config.Parameter<DateTime>("newDate");
config.Returns<Product>();
Metadata generated:
----------------------
<FunctionImport Name="ExtendSupportDate" ReturnType="ODataService.Models.Product" IsBindable="true">
<Parameter Name="bindingParameter" Type="ODataService.Models.Product"/>
<Parameter Name="newDate" Type="Edm.DateTime"/>
</FunctionImport>
This is a negative case and also there are comments on this API. Users could use api like ReturnsFromEntitySet or ReturnsCollectionFromEntitySet to avoid the problem here.