标签:style blog class code java c
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 > 1).ToList<MyClass>(); } finally { mongo.Disconnect(); } }
Mongo:将查询结果转换为自定义类,布布扣,bubuko.com
标签:style blog class code java c
原文地址:http://www.cnblogs.com/gossip/p/3723883.html