LINQ Exception when Lists of Documents containing Lists - Querying MongoDB Entity Framework Core
We are doing some development on the EF Core Library for MongoDB. It's in preview, so I'm trying to work out if this is a bug or a feature (or lack of a feature).
We are not doing any queries on these elements yet, but when the problematic collection is queried, if the problematic element is defined, we're running into problems.
public class Template
{
public ObjectId _id { get; set; }
public string name { get; set; }
public bool inheritFrom { get; set; }
public List<CallRound> callRounds { get; set; } //this is a list of sub documents with a list, it complains
public Qualifier qualifiers { get; set; } // this is a sub document with a list, it doesn't complain
}
public class CallRound
{
public List<CollectionReference>? jobQualifiers { get; set; } //this is the offender, if we comment out this code, the query functions
public bool isOvertime { get; set; }
public bool offerOrientedOnly { get; set; }
public string genderRequirements { get; set; }
}
public class Qualifier
{
public ObjectId worksiteId { get; set; }
public ObjectId jobClassificationId { get; set; }
public List<CollectionReference> jobQualifiers { get; set; }
public string genderRequirements { get; set; }
}
Question is, is there something wrong with my mapping? Or the library itself? Here's the mapping.
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Callout>().ToCollection("Callout");
modelBuilder.Entity<Template>().ToCollection("CalloutTemplate")
.OwnsMany<CallRound>("callRounds")
.OwnsMany<OtherCollectionReference>("jobQualifiers").WithOwner();
modelBuilder.Entity<JobClassification>().ToCollection("JobClassification");
modelBuilder.Entity<JobQualifier>().ToCollection("JobQualifier");
modelBuilder.Entity<Region>().ToCollection("Region");
modelBuilder.Entity<Worksite>().ToCollection("Worksite");
}
Finally, here's the call stack:
Result: Function 'CalloutBuilder', Invocation id '911c14d5-8c51-4148-b67a-6ce7588a383f': An exception was thrown by the invocation.
Exception: System.AggregateException: One or more errors occurred. (The LINQ expression 'o' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.)
Comments
Post a Comment