Created
February 22, 2024 17:46
-
-
Save atomaras/335bda36b3c03faeddc4b66f2483386f to your computer and use it in GitHub Desktop.
Odata.Core v7.18 regression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.OData.ModelBuilder; | |
using Microsoft.OData.UriParser; | |
namespace LearnOdata; | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// create the Edm Model | |
var b = new ODataModelBuilder(); | |
b.ComplexType<EntityMetadata>().HasDynamicProperties(m => m.DynamicProperties); | |
var entityType = b.EntityType<Entity>(); | |
entityType.HasKey(e => e.id); | |
entityType.ComplexProperty(e => e.metadata); | |
b.EntitySet<Entity>("entities"); | |
var model = b.GetEdmModel(); | |
var parser = new ODataQueryOptionParser( | |
model: model, | |
targetEdmType: model.FindDeclaredType(typeof(Entity).FullName), | |
targetNavigationSource: null, | |
queryOptions: new Dictionary<string, string>() | |
{ | |
{ "$filter", "metadata/intProp in (1,2)" } | |
}); | |
try | |
{ | |
var filterClause = parser.ParseFilter(); | |
} | |
catch (Exception ex) | |
{ | |
// Notice the error here. | |
throw; | |
} | |
} | |
} | |
class Entity | |
{ | |
public string id { get; set; } | |
public EntityMetadata metadata { get; set; } | |
} | |
class EntityMetadata | |
{ | |
public IDictionary<string, object> DynamicProperties { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment