reach4thelasers
reach4thelasers

Reputation: 26899

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

Upvotes: 0

Views: 336

Answers (1)

Victor Trusov
Victor Trusov

Reputation: 1222

It's

Queryable<FormSectionColumnLayoutReadModel>()
  .Where(x => affectedFormFieldsIds.Any(a => x.Fields.Contains(a)));

Upvotes: 1

Related Questions