Я пытаюсь создать запрос MongoDB LINQ, передавая список объектов в качестве параметра. Я перехожу к методу IEnumerable collection:
IEnumerable<(double latitude, double longitude)> coords
И я строю следующий запрос:
var q =
GetDbCollection()
.AsQueryable()
.Where(x => coords.Any(c => x.Longitude == c.longitude && x.Latitude == c.latitude))
.OrderByDescending(x => x.Date)
.Take(coords.Count());
GetDbCollection()
имеет следующую реализацию:
internal IMongoCollection<T> GetDbCollection(string name = "")
{
if (string.IsNullOrWhiteSpace(name)) name = typeof(T).Name;
var client = new MongoClient(_dbContext.ConnectionString);
var database = client.GetDatabase(_dbContext.DatabaseName);
var collection = database.GetCollection<T>(name);
return collection;
}
Эта часть запроса не работает:
Where(x => coords.Any(c => x.Longitude == c.longitude && x.Latitude == c.latitude))
Я получаю следующее исключение:
Неподдерживаемый фильтр: Любой (значение (System.Linq.Enumerable + SelectListIterator 2[Models.Coordinate,System.ValueTuple
2 [System.Double, System.Double]]). Где ((({{document} {Longitude} == {document} {Item2}) AndAlso ({document} {Latitude} == {document} { Item1})))).