I know, it's a known issue, but there's something fishy:
Here's my models
class PhoneBookCategory
{
public Guid Id { get; set; }
[BsonRef("PhoneBook")]
public List<PhoneBook> PhoneBooks { get; set; }
}
class PhoneBook
{
public Guid Id { get; set; }
}
And here's how I'm trying to query:
List<Guid> ids = [Guid.NewGuid()];
var set = GetCollection<PhoneBookCategory>().Query().Where(x => x.PhoneBooks.Select(x => x.Id).Any(x => ids.Contains(x)))
And it throws. But... I have a simple condition, no? x.PhoneBooks.Select(x => x.Id).Any(x => ids.Contains(x)), that's not performing an any over a full collection, only a list of Ids.
The exception message being x.Customers.Select(c => c.Name).Any(n => n.StartsWith('J')) to me it seems this is the same thing, no?
Could it be an issue of subdocuments versus DbRefs? and if so, isn't the exception misleading in this case?
Also.. I know how to rewrite the above query - but what if I were to query a more complex variety:
var set = GetCollection<PhoneBookCategory>().Query().Where(x => x.PhoneBooks == null || x.PhoneBooks.Count == 0 || x.PhoneBooks.Select(x => x.Id).Any(x => ids.Contains(x)))
Is there a way to get the BsonExpression out of my two conditions so I can use the Query class to combine them together?
Version 5.0.17
I know, it's a known issue, but there's something fishy:
Here's my models
And here's how I'm trying to query:
And it throws. But... I have a simple condition, no?
x.PhoneBooks.Select(x => x.Id).Any(x => ids.Contains(x))
, that's not performing an any over a full collection, only a list of Ids.The exception message being
x.Customers.Select(c => c.Name).Any(n => n.StartsWith('J'))
to me it seems this is the same thing, no? Could it be an issue of subdocuments versus DbRefs? and if so, isn't the exception misleading in this case?Also.. I know how to rewrite the above query - but what if I were to query a more complex variety:
Is there a way to get the
BsonExpression
out of my two conditions so I can use theQuery
class to combine them together?