Aniket Narvankar

Aniket Narvankar

  • 558
  • 2.1k
  • 608.7k

How to construct an MongoDB Linq Any() query by comparing a sub-field

Apr 5 2021 7:47 AM
I need help on how to use linq Any with mongodb in c sharp
Following is the query I have written
builder.Where(d => d.DepartmentId == appSettings.ClientId && d.IsCompleted == 0 && d.ScanDate >= fromDate_ && d.ScanDate <= toDate_&&d => op.ProviderLocMappings.Any(pm => d.BatchDocumentEntity.ProviderName.Any(pnm => pnm.Name.Equals(pm.Key) && pnm.Selected == true) && pm.Value.Contains(d.BatchDocumentEntity.Location))).ToList();
It is returning list of documents 
 
But it gives me error unsupported filtered Type Any. Kindly guide me on this how to use Any over here