Click here to Skip to main content
Click here to Skip to main content
Articles » Database » NoSQL » General » Downloads
 
Add your own
alternative version

Using MongoDB with the Official C# Driver

, 24 Oct 2011
Introduces how to use MongoDB in your ASP.NET MVC project using the official C# driver.
IntroMongo_src.zip
IntroMongo
IntroMongo
bin
EntityFramework.dll
IntroMongo.dll
MongoDB.Bson.dll
MongoDB.Driver.dll
Content
themes
base
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Controllers
Global.asax
IntroMongo.csproj.user
Models
obj
Debug
TempPE
Properties
Scripts
Views
Remark
Shared
User
packages
EntityFramework.4.1.10331.0
EntityFramework.4.1.10331.0.nupkg
lib
EntityFramework.dll
jQuery.1.5.1
Content
Scripts
jQuery.1.5.1.nupkg
jQuery.UI.Combined.1.8.11
Content
Content
themes
base
images
ui-bg_flat_0_aaaaaa_40x100.png
ui-bg_flat_75_ffffff_40x100.png
ui-bg_glass_55_fbf9ee_1x400.png
ui-bg_glass_65_ffffff_1x400.png
ui-bg_glass_75_dadada_1x400.png
ui-bg_glass_75_e6e6e6_1x400.png
ui-bg_glass_95_fef1ec_1x400.png
ui-bg_highlight-soft_75_cccccc_1x100.png
ui-icons_222222_256x240.png
ui-icons_2e83ff_256x240.png
ui-icons_454545_256x240.png
ui-icons_888888_256x240.png
ui-icons_cd0a0a_256x240.png
Scripts
jQuery.UI.Combined.1.8.11.nupkg
jQuery.Validation.1.8.0
Content
Scripts
jQuery.Validation.1.8.0.nupkg
jQuery.vsdoc.1.5.1
Content
Scripts
jQuery.vsdoc.1.5.1.nupkg
Modernizr.1.7
Content
Scripts
Modernizr.1.7.nupkg
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MongoDB.Driver;

namespace IntroMongo.Models
{
    public class MongoWrapper
    {
        public static MongoDatabase GetDatabase()
        {
            // Create server settings to pass connection string, timeout, etc.
            MongoServerSettings settings = new MongoServerSettings();
            settings.Server = new MongoServerAddress("localhost", 27017);
            // Create server object to communicate with our server
            MongoServer server = new MongoServer(settings);
            // Get our database instance to reach collections and data
            var database = server.GetDatabase("MessageDB");

            return database;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ercan Anlama
Software Developer
Turkey Turkey
I started to development during university years and worked in many freelance projects. I am working in software development more than 4 years and currently, working as analyst software developer in an Holland centre company in Istanbul, Turkey. I am interested in innovation and creativity in software development and passionate in learning new stuff.
Follow on   Twitter

| Advertise | Privacy | Mobile
Web02 | 2.8.140826.1 | Last Updated 24 Oct 2011
Article Copyright 2011 by Ercan Anlama
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid