|
When querying against a property that is defined as an abstract base type the driver fails to handle a cast to a concrete type within the where clause.
The following example worked within the 1.92 of the C# driver.
Below is an example:
public class Entity
|
{
|
public A Result { get; set; }
|
}
|
|
[BsonKnownTypes(new Type[] { typeof(B), typeof(C)})]
|
public abstract class A
|
{
|
public string Id { get; set; }
|
}
|
|
public class B : A
|
{
|
public string PropertyOnB { get; set; }
|
}
|
|
public class C : A
|
{
|
public string PropertyOnC { get; set; }
|
}
|
Query:
collection.AsQueryable().Where(q => ((B)q.Result).PropertyOnB == "TestResult").ToList();
|
|
Executing this query gives the following exception:
|
|
Convert({document}{Results}).PropertyOnB is not supported
|
|