0
+<br />Using MongoDB on Windows with the .Net Framework and C#<br />
Let me introduce myself…<br />Stefano Paluello<br />All around geek   @ Barcrest Group & Pastesoft<br />stefano.paluello@...
What is MongoDB?<br />It’s an open source document oriented database:<br />Full index support<br />Replication & High Avai...
Setting up MongoDB on Windows<br />Download your version (better the 64bit Production release) from the official website:<...
Running MongoDB server…<br />Best place where to look at (Windows quickstart):<br />http://www.mongodb.org/display/DOCS/Qu...
Ok. Are we running?<br />Let’s connect to the shell and check it<br />$mongodirbinmongo.exe<br />
MongoDB can run as service<br />Official guide:<br />http://www.mongodb.org/display/DOCS/Windows+Service<br />Easy way: <b...
MongoDB C#/.Net driver<br />Official, high performance, fully featured C# driver supported by 10gen<br />Now at version 1....
MongoDB C#/.Net driver on NuGet<br />
MongoDB C#/.Net driver<br />Two main (separated) assemblies:<br />MongoDB.Bson.dll<br />MongoDB.Driver.dll (you can use ot...
BSON Namespace<br />Represent the BSON Object Model<br />A set of classes that handle all the specification of BSON docume...
BSON Object Model<br />BsonDocument is the main class<br />BsonDocument is a collection of elements (BsonElements )<br />B...
MongoDB.Driver<br />Main classes (all thread-safe):<br />MongoServer<br />MongoDatabase<br />MongoCollection<TDocument><br...
MongoDB.Driver<br />MongoServersrv = MongoServer.Create();<br />Every URL has a MongoServer instance <br />different Creat...
MongoDB Driver<br />MongoCollection :<br />The class manages a collection of BsonDocument in a MongoDB database<br />Mongo...
MongoCollection class<br />CRUD with Mongo – Query a collection<br />FindOne and FindOneAs<T><br />IMongoQuery objects (Qu...
MongoCollection class<br />CRUD with MongoDB - Insert<br />There are many ways to insert data into a MongoDB collection (u...
MongoCollection class<br />CRUD with MongoDB – Update and Save<br />There are many ways to update a document<br />
MongoCollection class<br />CRUD with MongoDB – Delete<br />There are many ways to delete a Document<br />
Let’s play a bit with the code…<br />
Useful (IMHO) tools<br />
MongoVue (www.mongovue.com)<br />
Chrome Webstore – Mongo Live<br />
Another code demo<br />Get dynamics with C#<br />
Upcoming SlideShare
Loading in...5
×

Using MongoDB with the .Net Framework

6,149

Published on

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
6,149
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
98
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Full index:Index on any attribute, just like you&apos;re used to.
  • Transcript of "Using MongoDB with the .Net Framework"

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

      Clipping is a handy way to collect important slides you want to go back to later.

    ×