Odata expand query result by default

前端 未结 2 1478
陌清茗
陌清茗 2021-01-22 11:29

Is there a way to auto expand nested entity in the response with odata 5.7?

Because by default we have to add ?$expand=myNestedEntity

相关标签:
2条回答
  • 2021-01-22 11:52

    As an alternative, this can be accomplished with fluent api.

    builder.EntitySet<MyType>("MyType").EntityType.Expand(SelectExpandType.Automatic, "ExpandedField1", "ExpandedField2");
    
    0 讨论(0)
  • 2021-01-22 12:02

    In your entity class definition, use the AutoExpand attribute on the navigation properties you would like to have expanded.

    Namespace: Microsoft.AspNet.OData.Builder

    Represents an Attribute that can be placed on a navigation property to specify it is auto expanded, or placed on a class to specify all navigation properties are auto expanded.

    0 讨论(0)
提交回复
热议问题