Your SlideShare is downloading. ×
0
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Using MongoDB with the .Net Framework
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Using MongoDB with the .Net Framework

5,952

Published on

Connect to a MongoDB database using the official C# driver from 10gen

Connect to a MongoDB database using the official C# driver from 10gen

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,952
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
95
Comments
0
Likes
7
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Full index:Index on any attribute, just like you're used to.
  • Transcript

    • 1. +
      Using MongoDB on Windows with the .Net Framework and C#
    • 2. Let me introduce myself…
      Stefano Paluello
      All around geek  @ Barcrest Group & Pastesoft
      stefano.paluello@gmail.com
      stefanopaluello.wordpress.com
      Twitter: @palutz
      http://www.pastesoft.com
    • 3. What is MongoDB?
      It’s an open source document oriented database:
      Full index support
      Replication & High Availability
      Scalable (auto-sharding)
      High performance (written in C++, atomic update,…)
      Rich query support
      Map/Reduce
      GridFS (store files without problem)
      Commercial support
    • 4. Setting up MongoDB on Windows
      Download your version (better the 64bit Production release) from the official website:
      http://www.mongodb.org/downloads
    • 5. Running MongoDB server…
      Best place where to look at (Windows quickstart):
      http://www.mongodb.org/display/DOCS/Quickstart+Windows
      Unzip, create log and data dir, run it 
    • 6. Ok. Are we running?
      Let’s connect to the shell and check it
      $mongodirbinmongo.exe
    • 7. MongoDB can run as service
      Official guide:
      http://www.mongodb.org/display/DOCS/Windows+Service
      Easy way:
      $mongodirbinmongod –install
      Let’s add some “flavour”:
      $mongodirbinmongod --logpath .loglogs --logappend --dbpath .data –directoryperdb –install
      To manage it, NET START mongos, NET STOP mongos
    • 8. MongoDB C#/.Net driver
      Official, high performance, fully featured C# driver supported by 10gen
      Now at version 1.2
      Built and tested against MongoDB 1.8.3 e 2.0.0 on :
      Visual Studio 2008, Visual Studio 2010
      MonoDevelop 2.6 (Mono 2.10)
      It can be downloaded from github.com: http://github.com/mongodb/mongo-csharp-driver
      NuGet:
      PM> Install-Package mongocsharpdriver
      http://www.nuget.org/List/Packages/mongocsharpdriver
    • 9. MongoDB C#/.Net driver on NuGet
    • 10. MongoDB C#/.Net driver
      Two main (separated) assemblies:
      MongoDB.Bson.dll
      MongoDB.Driver.dll (you can use other drivers)
      Namespaces (required)
      MongoDB.Bson;
      MongoDB.Driver;
      Namespace (additional)
      MongoDB.Bson.IO, MongoDB.Bson.Serialization; MongoDB.Bson.Serialization.*, MongoDB.Driver.GridFs
    • 11. BSON Namespace
      Represent the BSON Object Model
      A set of classes that handle all the specification of BSON documents (I/O, serialization, in-memory object model)
      Main classes:
      BsonDocument
      BsonElement
      BsonValue (abstract class), with BsonTypeenum property
      BsonArray
      BsonDateTime
      BsonDocument
      BsonInt32
      BsonObjectId
      BsonString
    • 12. BSON Object Model
      BsonDocument is the main class
      BsonDocument is a collection of elements (BsonElements )
      BsonElement is a name/value pair where the value is a BsonValue (with its own BsonType)
      The BsonElement class is seldom used directly cause it’s created as needed implicitly:
      document.Add(new BsonElement(“Name”, “Stefano”));
      document.Add(“Name”, “Stefano”));
    • 13. MongoDB.Driver
      Main classes (all thread-safe):
      MongoServer
      MongoDatabase
      MongoCollection<TDocument>
      MongoCursor<Tdocument> (only when frozen)
      MongoServersrv = MongoServer.Create();
      Every URL has a MongoServer instance (different Create calls with the same URL return with the same MongoServer instance
      NOT put in the session state (NOT serializable)
    • 14. MongoDB.Driver
      MongoServersrv = MongoServer.Create();
      Every URL has a MongoServer instance
      different Create() calls with the same URL return with the same MongoServerinstance
      Do NOT put in the session state (NOT serializable)
      The driver manage a Connection Pools (one Connection Pools for every server)
      The connections are shared with all threads
    • 15. MongoDB Driver
      MongoCollection :
      The class manages a collection of BsonDocument in a MongoDB database
      MongoCollection<TDefaultDocument>:
      Manage a collection of document, with the default type specified by the TDefaultDocument parameter
      GetCollection
    • 16. MongoCollection class
      CRUD with Mongo – Query a collection
      FindOne and FindOneAs<T>
      IMongoQuery objects (QueryComplete)
      Find(query)
    • 17. MongoCollection class
      CRUD with MongoDB - Insert
      There are many ways to insert data into a MongoDB collection (using the BsonDocument or any object that can be serialized
    • 18. MongoCollection class
      CRUD with MongoDB – Update and Save
      There are many ways to update a document
    • 19. MongoCollection class
      CRUD with MongoDB – Delete
      There are many ways to delete a Document
    • 20. Let’s play a bit with the code…
    • 21. Useful (IMHO) tools
    • 22. MongoVue (www.mongovue.com)
    • 23. Chrome Webstore – Mongo Live
    • 24. Another code demo
      Get dynamics with C#

    ×