SlideShare a Scribd company logo
+Using MongoDB on Windows with the .Net Framework and C#
Let me introduce myself…Stefano PaluelloAll around geek   @ Barcrest Group & Pastesoftstefano.paluello@gmail.comstefanopaluello.wordpress.comTwitter: @palutzhttp://www.pastesoft.com
What is MongoDB?It’s an open source document oriented database:Full index supportReplication & High AvailabilityScalable (auto-sharding)High performance (written in C++, atomic update,…)Rich query supportMap/ReduceGridFS (store files without problem)Commercial support
Setting up MongoDB on WindowsDownload your version (better the 64bit Production release) from the official website:http://www.mongodb.org/downloads
Running MongoDB server…Best place where to look at (Windows quickstart):http://www.mongodb.org/display/DOCS/Quickstart+WindowsUnzip, create log and data dir, run it 
Ok. Are we running?Let’s connect to the shell and check it$mongodir\bin\mongo.exe
MongoDB can run as serviceOfficial guide:http://www.mongodb.org/display/DOCS/Windows+ServiceEasy way: $mongodir\bin\mongod  –installLet’s add some “flavour”:$mongodir\bin\mongod --logpath .\log\logs --logappend --dbpath .\data –directoryperdb –installTo manage it, NET START mongos, NET STOP mongos
MongoDB C#/.Net driverOfficial, high performance, fully featured C# driver supported by 10genNow at version 1.2Built and tested against MongoDB 1.8.3 e 2.0.0 on :Visual Studio 2008, Visual Studio 2010MonoDevelop 2.6 (Mono 2.10)It can be downloaded from github.com: 	http://github.com/mongodb/mongo-csharp-driverNuGet:PM> Install-Package mongocsharpdriverhttp://www.nuget.org/List/Packages/mongocsharpdriver
MongoDB C#/.Net driver on NuGet
MongoDB C#/.Net driverTwo main (separated) assemblies:MongoDB.Bson.dllMongoDB.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
BSON NamespaceRepresent the BSON Object ModelA set of classes that handle all the specification of BSON documents (I/O, serialization, in-memory object model)Main classes:BsonDocumentBsonElementBsonValue (abstract class), with BsonTypeenum propertyBsonArrayBsonDateTimeBsonDocumentBsonInt32BsonObjectIdBsonString
BSON Object ModelBsonDocument is the main classBsonDocument 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”));
MongoDB.DriverMain classes (all thread-safe):MongoServerMongoDatabaseMongoCollection<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 instanceNOT put in the session state (NOT serializable)
MongoDB.DriverMongoServersrv = MongoServer.Create();Every URL has a MongoServer instance different Create() calls with the same URL return with the same MongoServerinstanceDo 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
MongoDB DriverMongoCollection :The class manages a collection of BsonDocument in a MongoDB databaseMongoCollection<TDefaultDocument>:Manage a collection of document, with the default type specified by the TDefaultDocument parameterGetCollection
MongoCollection classCRUD with Mongo – Query a collectionFindOne and FindOneAs<T>IMongoQuery objects (QueryComplete)Find(query)
MongoCollection classCRUD with MongoDB - InsertThere are many ways to insert data into a MongoDB collection (using the BsonDocument or any object that can be serialized
MongoCollection classCRUD with MongoDB – Update and SaveThere are many ways to update a document
MongoCollection classCRUD with MongoDB – DeleteThere are many ways to delete a Document
Let’s play a bit with the code…
Useful (IMHO) tools
MongoVue (www.mongovue.com)
Chrome Webstore – Mongo Live
Another code demoGet dynamics with C#

More Related Content

What's hot (20)

PDF
Hazelcast Distributed Lock
Jadson Santos
 
PDF
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Web Services Korea
 
PPTX
C10k and beyond - Uri Shamay, Akamai
Codemotion Tel Aviv
 
PPTX
Grokking Techtalk #40: Consistency and Availability tradeoff in database cluster
Grokking VN
 
PDF
AWS Black Belt Techシリーズ Amazon CloudSearch
Amazon Web Services Japan
 
PDF
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kai Wähner
 
PPTX
File Format Benchmark - Avro, JSON, ORC and Parquet
DataWorks Summit/Hadoop Summit
 
PDF
내 서비스에는 어떤 데이터베이스가 맞는걸까? - 이혁 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
Amazon Web Services Korea
 
PDF
EKS를 통한 차량 공유 서비스 '타다' 서비스 구축기 - 김태호, VCNC :: AWS Summit Seoul 2019
Amazon Web Services Korea
 
PDF
Celery: The Distributed Task Queue
Richard Leland
 
PPTX
Fortify - Source Code Analyzer
n|u - The Open Security Community
 
PDF
ISMS 개발보안, 시큐어코딩을 위한 sonarqube의 활용.건국대학교병원.이제관 기술사
제관 이
 
PDF
Event Streaming with Kafka Streams and Spring Cloud Stream | Soby Chacko, VMware
HostedbyConfluent
 
PDF
Clean architectures with fast api pycones
Alvaro Del Castillo
 
PDF
How to use Parquet as a basis for ETL and analytics
Julien Le Dem
 
ODP
OWASP Secure Coding
bilcorry
 
PDF
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Websecurify
 
PDF
Ad-Tech on AWS 세미나 | AWS와 실시간 입찰
Amazon Web Services Korea
 
PDF
AWS 클라우드 기반 나의 첫 웹 애플리케이션 만들기 – 윤석찬 :: AWS Builders Online Series
Amazon Web Services Korea
 
PDF
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
DirkjanMollema
 
Hazelcast Distributed Lock
Jadson Santos
 
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Web Services Korea
 
C10k and beyond - Uri Shamay, Akamai
Codemotion Tel Aviv
 
Grokking Techtalk #40: Consistency and Availability tradeoff in database cluster
Grokking VN
 
AWS Black Belt Techシリーズ Amazon CloudSearch
Amazon Web Services Japan
 
Kafka Streams vs. KSQL for Stream Processing on top of Apache Kafka
Kai Wähner
 
File Format Benchmark - Avro, JSON, ORC and Parquet
DataWorks Summit/Hadoop Summit
 
내 서비스에는 어떤 데이터베이스가 맞는걸까? - 이혁 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
Amazon Web Services Korea
 
EKS를 통한 차량 공유 서비스 '타다' 서비스 구축기 - 김태호, VCNC :: AWS Summit Seoul 2019
Amazon Web Services Korea
 
Celery: The Distributed Task Queue
Richard Leland
 
Fortify - Source Code Analyzer
n|u - The Open Security Community
 
ISMS 개발보안, 시큐어코딩을 위한 sonarqube의 활용.건국대학교병원.이제관 기술사
제관 이
 
Event Streaming with Kafka Streams and Spring Cloud Stream | Soby Chacko, VMware
HostedbyConfluent
 
Clean architectures with fast api pycones
Alvaro Del Castillo
 
How to use Parquet as a basis for ETL and analytics
Julien Le Dem
 
OWASP Secure Coding
bilcorry
 
Secure Coding - Web Application Security Vulnerabilities and Best Practices
Websecurify
 
Ad-Tech on AWS 세미나 | AWS와 실시간 입찰
Amazon Web Services Korea
 
AWS 클라우드 기반 나의 첫 웹 애플리케이션 만들기 – 윤석찬 :: AWS Builders Online Series
Amazon Web Services Korea
 
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
DirkjanMollema
 

Similar to Using MongoDB with the .Net Framework (20)

PPTX
Introduction to the new official C# Driver developed by 10gen
MongoDB
 
KEY
Welcome the Offical C# Driver for MongoDB
MongoDB
 
ODP
Mongo db rev001.
Rich Helton
 
PDF
Mongo db first steps with csharp
Serdar Buyuktemiz
 
PDF
Mongo db for c# developers
Simon Elliston Ball
 
PPTX
Getting Started with MongoDB Using the Microsoft Stack
MongoDB
 
PDF
Building Your First MongoDB Application
Tugdual Grall
 
PPTX
Webinar: What's new in the .NET Driver
MongoDB
 
PDF
NDC London 2013 - Mongo db for c# developers
Simon Elliston Ball
 
PDF
MongoDB
Serdar Buyuktemiz
 
PPTX
MongoDB presentation
Hyphen Call
 
PDF
Introduction to MongoDB Basics from SQL to NoSQL
Mayur Patil
 
PDF
MongodB Internals
Norberto Leite
 
PPTX
introtomongodb
saikiran
 
PPTX
Python mongo db-training-europython-2011
Andreas Jung
 
PPTX
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 
PPTX
Mongodb Introduction
Nabeel Naqeebi
 
PDF
10gen MongoDB Video Presentation at WebGeek DevCup
WebGeek Philippines
 
PDF
Node Js, AngularJs and Express Js Tutorial
PHP Support
 
PPT
Introduction to MongoDB
Ravi Teja
 
Introduction to the new official C# Driver developed by 10gen
MongoDB
 
Welcome the Offical C# Driver for MongoDB
MongoDB
 
Mongo db rev001.
Rich Helton
 
Mongo db first steps with csharp
Serdar Buyuktemiz
 
Mongo db for c# developers
Simon Elliston Ball
 
Getting Started with MongoDB Using the Microsoft Stack
MongoDB
 
Building Your First MongoDB Application
Tugdual Grall
 
Webinar: What's new in the .NET Driver
MongoDB
 
NDC London 2013 - Mongo db for c# developers
Simon Elliston Ball
 
MongoDB presentation
Hyphen Call
 
Introduction to MongoDB Basics from SQL to NoSQL
Mayur Patil
 
MongodB Internals
Norberto Leite
 
introtomongodb
saikiran
 
Python mongo db-training-europython-2011
Andreas Jung
 
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 
Mongodb Introduction
Nabeel Naqeebi
 
10gen MongoDB Video Presentation at WebGeek DevCup
WebGeek Philippines
 
Node Js, AngularJs and Express Js Tutorial
PHP Support
 
Introduction to MongoDB
Ravi Teja
 
Ad

More from Stefano Paluello (10)

PPTX
Clinical Data and AI
Stefano Paluello
 
PPTX
Real scenario: moving a legacy app to the Cloud
Stefano Paluello
 
PPTX
A gentle introduction to the world of BigData and Hadoop
Stefano Paluello
 
PPTX
Grandata
Stefano Paluello
 
PDF
How to use asana
Stefano Paluello
 
PDF
Windows Azure Overview
Stefano Paluello
 
PPTX
TDD with Visual Studio 2010
Stefano Paluello
 
PPTX
Asp.Net MVC Intro
Stefano Paluello
 
PPTX
Entity Framework 4
Stefano Paluello
 
PPTX
Teamwork and agile methodologies
Stefano Paluello
 
Clinical Data and AI
Stefano Paluello
 
Real scenario: moving a legacy app to the Cloud
Stefano Paluello
 
A gentle introduction to the world of BigData and Hadoop
Stefano Paluello
 
How to use asana
Stefano Paluello
 
Windows Azure Overview
Stefano Paluello
 
TDD with Visual Studio 2010
Stefano Paluello
 
Asp.Net MVC Intro
Stefano Paluello
 
Entity Framework 4
Stefano Paluello
 
Teamwork and agile methodologies
Stefano Paluello
 
Ad

Recently uploaded (20)

PPTX
Essential Content-centric Plugins for your Website
Laura Byrne
 
PPTX
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
Manual Testing for Accessibility Enhancement
Julia Undeutsch
 
PDF
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
 
Essential Content-centric Plugins for your Website
Laura Byrne
 
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Digital Circuits, important subject in CS
contactparinay1
 
Manual Testing for Accessibility Enhancement
Julia Undeutsch
 
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Software Development Company Keene Systems, Inc (1).pdf
Custom Software Development Company | Keene Systems, Inc.
 

Using MongoDB with the .Net Framework

  • 1. +Using MongoDB on Windows with the .Net Framework and C#
  • 2. Let me introduce myself…Stefano PaluelloAll around geek  @ Barcrest Group & Pastesoftstefano.paluello@gmail.comstefanopaluello.wordpress.comTwitter: @palutzhttp://www.pastesoft.com
  • 3. What is MongoDB?It’s an open source document oriented database:Full index supportReplication & High AvailabilityScalable (auto-sharding)High performance (written in C++, atomic update,…)Rich query supportMap/ReduceGridFS (store files without problem)Commercial support
  • 4. Setting up MongoDB on WindowsDownload 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+WindowsUnzip, create log and data dir, run it 
  • 6. Ok. Are we running?Let’s connect to the shell and check it$mongodir\bin\mongo.exe
  • 7. MongoDB can run as serviceOfficial guide:http://www.mongodb.org/display/DOCS/Windows+ServiceEasy way: $mongodir\bin\mongod –installLet’s add some “flavour”:$mongodir\bin\mongod --logpath .\log\logs --logappend --dbpath .\data –directoryperdb –installTo manage it, NET START mongos, NET STOP mongos
  • 8. MongoDB C#/.Net driverOfficial, high performance, fully featured C# driver supported by 10genNow at version 1.2Built and tested against MongoDB 1.8.3 e 2.0.0 on :Visual Studio 2008, Visual Studio 2010MonoDevelop 2.6 (Mono 2.10)It can be downloaded from github.com: http://github.com/mongodb/mongo-csharp-driverNuGet:PM> Install-Package mongocsharpdriverhttp://www.nuget.org/List/Packages/mongocsharpdriver
  • 10. MongoDB C#/.Net driverTwo main (separated) assemblies:MongoDB.Bson.dllMongoDB.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 NamespaceRepresent the BSON Object ModelA set of classes that handle all the specification of BSON documents (I/O, serialization, in-memory object model)Main classes:BsonDocumentBsonElementBsonValue (abstract class), with BsonTypeenum propertyBsonArrayBsonDateTimeBsonDocumentBsonInt32BsonObjectIdBsonString
  • 12. BSON Object ModelBsonDocument is the main classBsonDocument 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.DriverMain classes (all thread-safe):MongoServerMongoDatabaseMongoCollection<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 instanceNOT put in the session state (NOT serializable)
  • 14. MongoDB.DriverMongoServersrv = MongoServer.Create();Every URL has a MongoServer instance different Create() calls with the same URL return with the same MongoServerinstanceDo 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 DriverMongoCollection :The class manages a collection of BsonDocument in a MongoDB databaseMongoCollection<TDefaultDocument>:Manage a collection of document, with the default type specified by the TDefaultDocument parameterGetCollection
  • 16. MongoCollection classCRUD with Mongo – Query a collectionFindOne and FindOneAs<T>IMongoQuery objects (QueryComplete)Find(query)
  • 17. MongoCollection classCRUD with MongoDB - InsertThere are many ways to insert data into a MongoDB collection (using the BsonDocument or any object that can be serialized
  • 18. MongoCollection classCRUD with MongoDB – Update and SaveThere are many ways to update a document
  • 19. MongoCollection classCRUD with MongoDB – DeleteThere are many ways to delete a Document
  • 20. Let’s play a bit with the code…
  • 23. Chrome Webstore – Mongo Live
  • 24. Another code demoGet dynamics with C#

Editor's Notes

  • #4: Full index:Index on any attribute, just like you&apos;re used to.
  • #5: Full index:Index on any attribute, just like you&apos;re used to.
  • #6: Full index:Index on any attribute, just like you&apos;re used to.
  • #7: Full index:Index on any attribute, just like you&apos;re used to.
  • #8: Full index:Index on any attribute, just like you&apos;re used to.
  • #9: Full index:Index on any attribute, just like you&apos;re used to.
  • #10: Full index:Index on any attribute, just like you&apos;re used to.
  • #11: Full index:Index on any attribute, just like you&apos;re used to.
  • #12: Full index:Index on any attribute, just like you&apos;re used to.
  • #13: Full index:Index on any attribute, just like you&apos;re used to.
  • #14: Full index:Index on any attribute, just like you&apos;re used to.
  • #15: Full index:Index on any attribute, just like you&apos;re used to.
  • #16: Full index:Index on any attribute, just like you&apos;re used to.
  • #17: Full index:Index on any attribute, just like you&apos;re used to.
  • #18: Full index:Index on any attribute, just like you&apos;re used to.
  • #19: Full index:Index on any attribute, just like you&apos;re used to.
  • #20: Full index:Index on any attribute, just like you&apos;re used to.
  • #22: Full index:Index on any attribute, just like you&apos;re used to.
  • #23: Full index:Index on any attribute, just like you&apos;re used to.
  • #24: Full index:Index on any attribute, just like you&apos;re used to.
  • #25: Full index:Index on any attribute, just like you&apos;re used to.