I have built an EdmModel which contains an enum property, Level
.
var level = new EdmEnumType("Log.Api.Models",
"Level",
EdmPrimitiveTypeKind.Int32,
false);
level.AddMember(new EdmEnumMember(level, "Debug", new EdmIntegerConstant(0)));
level.AddMember(new EdmEnumMember(level, "Error", new EdmIntegerConstant(1)));
level.AddMember(new EdmEnumMember(level, "Info", new EdmIntegerConstant(2)));
Model.AddElement(level);
// add a property, named 'Level', of type 'Level'
logEntry.AddProperty(new EdmStructuralProperty(logEntry,
"Level",
new EdmEnumTypeReference(level, false)));
OData requests are then parsed in C# using
ODataUriParser.ParseFilter(filter,
Model,
(IEdmSchemaType) schemaElmnt);
But I'm so far unsuccessful in sending a request which specifies an enum value. I've tried with the fully-qualified enum...
"Level eq Log.Api.Models.Level.Error"
And without
"Level eq Error"
And I've tried enclosing it in single quotes
"Level eq 'Error'"
The exception message is
A binary operator with incompatible types was detected. Found operand types 'Log.Api.Models.Level' and 'Edm.String' for operator kind 'Equal'.'
What is the correct format? Or does the problem lie in my EdmModel?