2

How can I implement a typed Builder using string fieldname and value, like in the following code:

Builders<Profile>.Filter.Eq(fieldName, value)

I can implement it with BsonDocument data type, but I need to retrieve a typed Profile FilterDifinition.

i3arnon
  • 113,022
  • 33
  • 324
  • 344
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46

1 Answers1

1

There's an implicit conversion from string to FilterDefinition so you can use it just like you did. For example:

var profile = await collection.Find(Builders<Profile>.Filter.Eq("Name", "bar")).SingleAsync();
i3arnon
  • 113,022
  • 33
  • 324
  • 344