1,747
社区成员
发帖
与我相关
我的任务
分享
MongoServer mongodb = MongoServer.Create("mongodb://localhost");
MongoDatabase mongoDataBase = mongodb.GetDatabase("Test");
MongoCollection mongoCollection = mongoDataBase.GetCollection("Temp1");
mongodb.Connect();
List<TestEntity> InfoList=new List<TestEntity>()
MongoCursor<TestEntity> mc = mongoCollection.FindAllAs<TestEntity>();
foreach (TestEntity _mc in mc)
{
TestEntity Info = new TestEntity();
Info.ID=_mc.ID;
Info.Name=_mc.Name.ToString();
InfoList.Add(Info)
}
public class TestEntity
{
public ObjectId _id { get; set; }
public string Name{ get; set; }
public int ID { get; set; }
}