Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Feature: Enum support in WebApi [1584]

$
0
0
WebApi treats Enum type as String and processes Enum type specially.
Since OData V4 supports Enum type, we want to support Enum type in WebApi after OData migrates to V4.
ODataModelBuilder, ODataConventionModelBuilder, serialization, deserialization and query should be modified to support this feature.
Comments: Now it will report error if adding an action with Enum type as parameter: private static IEdmModel GetConventionModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); EntitySetConfiguration<Employee> eTagsCustomersSet = builder.EntitySet<Employee>("Employees"); var employee = eTagsCustomersSet.EntityType; var actionConfiguration = employee.Action("AddSkill"); actionConfiguration.Parameter<Skill>("skill"); actionConfiguration.ReturnsCollection<Skill>(); return builder.GetEdmModel(); } Where Skill is an Enum type. and the error is: System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---- System.InvalidCastException : Unable to cast object of type 'Microsoft.OData.Edm.Library.EdmComplexType' to type 'Microsoft.OData.Edm.IEdmEnumType'. Result1 StackTrace: Server stack trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>