1

Closed

Return type of an Action is always added as Complex type even if type has key property

description

In the below example, Customer has 'Id' property. So, we need to create a Customer entity type rather than a complex type.

Type:
public class Customer
{
    public int Id { get; set; }

    public string Name { get; set; }
}
ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
var products = modelBuilder.EntitySet<Product>("Products");
var productFamilies = modelBuilder.EntitySet<ProductFamily>("ProductFamilies");
var suppliers = modelBuilder.EntitySet<Supplier>("Suppliers");

ActionConfiguration extendSupportAction = new ActionConfiguration(modelBuilder, "ExtendSupport");
extendSupportAction.Parameter<int>("id");
extendSupportAction.Parameter<DateTime>("newDate");
extendSupportAction.Returns<Customer>();

Metadata:
<ComplexType Name="Customer">
<Property Name="Id" Type="Edm.Int32" Nullable="false"/>
<Property Name="Name" Type="Edm.String"/>
</ComplexType>
Closed Oct 4, 2012 at 10:53 PM by HongmeiG
Use ReturnsFromEntitySet() instead if this is Entityset type.

comments