I have a IMongoCollection of contents:
collection = [
{Value = 'x', EntryPoint= 'ROOT/1' },
{Value = 'y', EntryPoint= 'ROOT/2' },
{Value = 'z', EntryPoint= 'OTHER/1' }]
now I want to filter my collections with
userEntryPoints = ['ROOT', 'SPECIAL'].
We defined, if I have entrypoint = 'ROOT', it is equivalant that we have entrypoint of 'ROOT/1', 'ROOT2' too.
So the expected result is
result = [
{Value = 'x', EntryPoint= 'ROOT/1' },
{Value = 'y', EntryPoint= 'ROOT/2' }]
The code I am using is
var collection = mongoDatabase.GetCollection(Data);
return collection.AsQueryable().Select(xxx)
.Where(item => userEntryPoints.Any( entrypoint => item.EntryPoint.StartsWith(entrypoint)))
This should work if collection and userEntryPoints are simple array.
But in my code, at runtime I have a mongodb error:
Unsupported filter: Any(value(System.Collections.Generic.List`1[System.String]].Where({document}{EntryPoint}.StarsWith(document))))
At MongoDB.Driver.Linq.Traslators.PredicateTranslator.Translate(Expression node)
What can I do to make such filtering possible? Thank you.