WebApi
WebApi copied to clipboard
Support for generic types in EDM
Please add support for generic types in the EDM model generated metadata.
My model has an intermediate generic abstract base class that looks like this:
public abstract class DynamicFieldValueBase { }
public abstract class DynamicFieldValueBase<T> : DynamicFieldValueBase
{
public T Value { get; set; }
}
public class TextDynamicFieldValue : DynamicFieldValueBase<string> { }
The edm for the intermediate generic class gets the following EDMX:
<ComplexType Name="DynamicFieldValueBase_1OfT" BaseType="MyProject.Data.DynamicFieldValueBase" Abstract="true">
<Property Name="Value" Type="MyProject.Data.T" />
</ComplexType>
<ComplexType Name="T" />
Assemblies affected
- Microsoft.OData.Edm
- Microsoft.OData.Core ?
Reproduce steps
Try exposing a generic type throughout the EDM model.
Expected result
A generic type edm entity
Actual result
The generic entity isn't recognized as such and is generated as a non-generic entity.
Migrated from here.
@weitzhandler could you please share how you build the model that results in the CSDL that you have shown. As of today, the standard does not support generic types. Seeing how you build the model will help to understand what happens in the mapping from C# to CSDL.
I undid everything having generics, but it was working in such way that I exposed DynamicFieldValueBase
as an entity type in the EDM.
Are there any plans to support generics?