MongoDB LINQ ContainsAny Unsupported Filter

I’m refactoring away from the .NET Legacy MongoDB Drivers. I’ve got a query that’s written using the Legacy API’s ContainsAny() method. In the query below affectedFormFieldIds is a list of IDs.

This Throws an ArgumentException stating that this is an Unsupported Filter.

Queryable<FormSectionColumnLayoutReadModel>().Where(x => x.Fields.ContainsAny(affectedFormFieldsIds)); 

How do I rewrite this query using the new API

Add Comment
1 Answer(s)

It’s

Queryable<FormSectionColumnLayoutReadModel>()   .Where(x => affectedFormFieldsIds.Any(a => x.Fields.Contains(a))); 
Answered on July 16, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.