1、自定义类
public class MyClass
{
public string Name { get; set; }
public int Corners { get; set; }
}
2、查询数据并转换
var config = new MongoConfigurationBuilder();
config.ConnectionString("");
using (Mongo mongo = new Mongo(config.BuildConfiguration()))
{
mongo.Connect();
try
{
var db = mongo.GetDatabase("MyTest");
var list = db.GetCollection<MyClass>("MyClass").Linq().ToList<MyClass>(); var superclass =
db.GetCollection<MyClass>("MyClass").Linq().Where(p => p.Corners > ).ToList<MyClass>();
}
finally
{
mongo.Disconnect();
}
}