OData opentype with MongoDb

I used MongoDB for the database and OData on my project

I have a model that has an open type is Dictionary<string, object>

public class DictionaryModel : Entity
        public DictionaryModel()
            Id = Guid.NewGuid();
            Name = Guid.NewGuid().ToString();
            Properties = new Dictionary<string, object>();

        public Guid Id { get; set; }
        public string Name { get; set; }
        public IDictionary<string, object> Properties { get; set; }

My controller:

 private readonly IDictionaryRepository _repository;
        public DictionaryController(IDictionaryRepository repository)
            _repository = repository;
            if (!repository.AsQueryable().Any())
                var data = new DictionaryModel();
                data.Properties.Add("String", "string 1");
                data.Properties.Add("Number", 1);
                data.Properties.Add("Boolean", true);

                var data2 = new DictionaryModel();
                data2.Properties.Add("String", "string 2");
                data2.Properties.Add("Number", 2);
                data2.Properties.Add("Boolean", false);


        public IQueryable<DictionaryModel> Get()
            return _repository.AsQueryable();

My ConfigureServices:

services.AddControllers().AddOData(opt =>
                opt.Count().Filter().Expand().Select().OrderBy().SetMaxTop(5000).AddRouteComponents("odata", GetEdmModel());
                opt.TimeZone = TimeZoneInfo.Utc;

My EDM Model:

private IEdmModel GetEdmModel()
            var odataBuilder = new ODataConventionModelBuilder();

            odataBuilder.EntityType<DictionaryModel>().HasKey(entity => entity.Id);

            return odataBuilder.GetEdmModel();

My Configure:

            // Add OData /$query middleware
            // Add the OData Batch middleware to support OData $Batch

When I send request to URL: /odata/Dictionary?$filter=String eq ‘string 1’

I received an error:

Convert(IIF((({document}{Properties} != null) AndAlso {document}{Properties}.ContainsKey(“String”)), {document}{Properties}.Item[“String”], null), String) is not supported.

I use:

Microsoft.AspNetCore.OData - v8.0.2
MongoDB.Driver - v2.13.1

How do I fix this issue?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.