Skip to content

Instantly share code, notes, and snippets.

@atomaras
Created February 22, 2024 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomaras/335bda36b3c03faeddc4b66f2483386f to your computer and use it in GitHub Desktop.
Save atomaras/335bda36b3c03faeddc4b66f2483386f to your computer and use it in GitHub Desktop.
Odata.Core v7.18 regression
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