public class News { public int _id { get; set; } public int count { get; set; } public string news { get; set; } public DateTime time { get; set; } } MongoCursor<BsonDocument> allDoc = coll.FindAllAs<BsonDocument>(); BsonDocument doc = allDoc.First(); //BsonDocument類型參數 MongoCursor<News> allNews = coll.FindAllAs<News>(); News aNew = allNews.First(); //News類型參數 News firstNews = coll.FindOneAs<News>(); //查找第一個文檔 QueryDocument query = new QueryDocument(); //定義查詢文檔 query.Add("_id", 10001); query.Add("count", 1); MongoCursor<News> qNews = coll.FindAs<News>(query); BsonDocument bd = new BsonDocument();//定義查詢文檔 count>2 and count<=4 bd.Add("$gt", 2); bd.Add("$lte", 4); QueryDocument query_a = new QueryDocument(); query_a.Add("count",bd); FieldsDocument fd = new FieldsDocument(); fd.Add("_id", 0); fd.Add("count", 1); fd.Add("time", 1); MongoCursor<News> mNewss = coll.FindAs<News>(query_a).SetFields(fd);//只返回count和time var time = BsonDateTime.Create("2011/9/5 23:26:00"); BsonDocument db_t = new BsonDocument(); db_t.Add("$gt", time); QueryDocument qd_3 = new QueryDocument(); qd_3.Add("time", db_t); MongoCursor<News> mNews = coll.FindAs<News>(qd_3);//