C#實現的MongoDB驅動:Simple-mongodb
Simple-mongodb 是一個C#實現的MongoDB驅動。重點就在于使用匿名類型和JSON來保持它的“動態”。
- 不需要繼承一個特定的基類
- 不需要映射
- 無需使用鍵 - 值字典 </ul>
插入示例:
var sessionFactory = new SimoSessionFactory(); using (var session = sessionFactory.GetSession("Pls.Simo.GettingStarted")) { var db = session["MyDatabase"]; var collection = db.GetCollection<InterestingUrl>(); var interestingUrl = new InterestingUrl(@"http://code.google.com/p/simple-mongodb") { Description = "The home of the Simple-MongoDB driver." }; interestingUrl.SetTags("Simple-MongoDB", "Project site"); collection.Insert(interestingUrl); }查詢示例:
var sessionFactory = new SimoSessionFactory(); using (var session = sessionFactory.GetSession("Pls.Simo.GettingStarted")) { var entityStore = new SimoEntityStore(session, "MyDatabase"); var interestingUrl = entityStore.FindOne<InterestingUrl>(new { Url = @"http://daniel.wertheim.se" }); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!