Update: I was using version 2.27.0 of the C# driver and have since found out that this seeming oversight was fixed as part of version 3.1.0 where these SearchDefinitionBuilder.Equals() method(s) were updated to remove the where TField : struct requirement and are documented as accepting string types.

Upgrading to > 3.1.0 resolved some of these issues for me however, I am still getting unexpected issues when trying to make use of enum based fields/values when building search definitions, for example, both of these attempts to add a filter results in an exception being thrown with the message:

Specified cast is not valid

A:

              .Filter( // Company based LegalPersons
                  Builders<LegalPerson>.Search.Equals<Entity.SubType>(
                      lp => lp.SubType,
                      Entity.SubType.Company
                  )
              )

B:

                .Filter( // In Draft or Live state
                    Builders<LegalPerson>.Search.In<ProfileStatus>(
                        lp => lp.Status,
                        new [] { ProfileStatus.Draft, ProfileStatus.Live }
                    )
                )

So instead I have had to resort to specifying the POCO property/fiueld name manually as a string and manually casting the enum options to their underlying Int32 value e.g.:

                .Filter( // Company based LegalPersons
                    Builders<LegalPerson>.Search.Equals<int>(
                        "subType",
                        (int)Entity.SubType.Company
                    )
                )
                .Filter( // In Draft or Live state
                    Builders<LegalPerson>.Search.In<int>(
                        "status",
                        new [] { (int)ProfileStatus.Draft, (int)ProfileStatus.Live }
                    )
                )

Which is I guess workable but quite annoying, any guidance on how I can achieve closer to the hope A/B above would be gratefully received?