Skip to content

Instantly share code, notes, and snippets.

@onyxmaster
Created August 9, 2023 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onyxmaster/7139baa4059cb2648d15d3be683d089f to your computer and use it in GitHub Desktop.
Save onyxmaster/7139baa4059cb2648d15d3be683d089f to your computer and use it in GitHub Desktop.
using MongoDB.Driver;
using MongoDB.Driver.Linq;
var filter = Builders<Document>.Filter.Gt(v => v.S, 1);
var settings = MongoClientSettings.FromConnectionString("mongodb://localhost:27017");
foreach (var provider in Enum.GetValues<LinqProvider>())
{
settings.LinqProvider = provider;
Console.Write($"Provider {provider}: ");
try
{
new MongoClient(settings)
.GetDatabase("test")
.GetCollection<Document>("test")
.Find(filter)
.FirstOrDefault();
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
continue;
}
Console.WriteLine("success");
}
record struct UserType(int Value)
{
public static implicit operator int(UserType self) => self.Value;
}
record Document(UserType S);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment