I'm trying to filter a collection like this
Builders<myClass>.Filter.Where(d => d.Name.IndexOf(".") > length)
but getting this error :
System.InvalidOperationException: {document}{Name}.IndexOf(".") is not supported.
Any way to achieve this ?
I'm trying to filter a collection like this
Builders<myClass>.Filter.Where(d => d.Name.IndexOf(".") > length)
but getting this error :
System.InvalidOperationException: {document}{Name}.IndexOf(".") is not supported.
Any way to achieve this ?
you need a linq expression that can generate the following aggregation pipeline:
db.collection.aggregate([
{
$match: {
$expr: {
$gt: [{ $indexOfCP: ['$name', '.'] }, 8]
}
}
}
])
but no such strongly-typed method exists in the c# driver unfortunately.
as an alternative to dealing with BsonDocuments, have a look at this.