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

Created Unassigned: OData Web API expression build for $select on entity property always wraps with a convert expression to a nullable type [1296]

$
0
0
1. Create an IEdmModel that that has an entity in which a structural property that is nullable = false is added:

EdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("Namespace", "Resources");
model.AddElement(container);
EdmEntityType vehicle = new EdmEntityType("Namespace", "Vehicle", null, false, false);
vehicle.AddStructuralProperty("Status", EdmPrimitiveTypeKind.String, false); // this is an Enum on the type
EdmStructuralProperty property = vehicle.AddStructuralProperty("VehicleId", EdmPrimitiveTypeKind.String, false);
vehicle.AddKeys(property);
model.AddElement(vehicle);
model.SetAnnotationValue<ClrTypeAnnotation>(vehicle, new ClrTypeAnnotation(typeof(Vehicle)));
var vehicles = container.AddEntitySet("Vehicles", vehicle);

2. Implement Get() method that returns an IQueryable of type Vehicle. On the IQueryable, make sure HandleNullPropagation = HandleNullPropagationOption.False.

3. Host the OData Web API and make the following call: ~/Vehicles?$select=Status

Get the following:

{Table(Dynamics.AX.Application.Vehicle).Select(Param_0 => new SelectSome`1() {ModelID = "cbe11608-9148-407f-b74d-80d477ac4f31", Container = new AutoSelectedNamedPropertyWithNext`1() {Name = "VehicleId", Value = Param_0.VehicleId, Next = new NamedProperty`1() {Name = "Status", Value = Convert(Param_0.Status)}}})}

Expected: No Value = Convert<Nullable<Enum>>(Param_0.Status)...

This causes issues, as must strip this out of the expression tree with a visitor if the LINQ Provider backend does not support Nullable<> types.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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