I hereby claim:
- I am jasonmccay on github.
- I am jasonmccay (https://keybase.io/jasonmccay) on keybase.
- I have a public key whose fingerprint is 5886 FE38 3715 07E3 45D4 ABC4 3AAE B861 0B72 064B
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
defaults: &defaults | |
autocreate_indexes: true | |
max_retries_on_connection_failure: 3 | |
allow_dynamic_fields: false | |
development: | |
host: localhost | |
database: taq_development |
using System.Collections.Generic; | |
using mongohq_csharp.Models.DTO; | |
namespace mongohq_csharp.Models | |
{ | |
public class DeveloperModel | |
{ | |
public IList<DeveloperDTO> developers { get; set; } | |
} | |
} |
public ActionResult Index() | |
{ | |
var model = new DeveloperModel(); | |
var developers_collection = mongo_db.GetCollection("developers").FindAll().AsEnumerable(); | |
model.developers = (from developer in developers_collection | |
select new DeveloperDTO | |
{ | |
id = developer["_id"].AsObjectId, | |
name = developer["name"].AsString, |
namespace mongohq_csharp.Models.DTO | |
{ | |
public class DeveloperDTO | |
{ | |
public BsonObjectId id { get; set; } | |
public string name { get; set; } | |
public string languages { get; set; } | |
public string company { get; set; } | |
} | |
} |
public class DeveloperController : Controller | |
{ | |
readonly MongoDatabase mongo_db; | |
public DeveloperController() | |
{ | |
mongo_db = retreive_mongohq_db(); | |
} | |
} |
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<mongohq_csharp.Models.DeveloperModel>" %> | |
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> | |
Index | |
</asp:Content> | |
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> | |
<h2>Developers</h2> |
using System.Collections.Generic; | |
using mongohq_csharp.Models.DTO; | |
namespace mongohq_csharp.Models | |
{ | |
public class DeveloperModel | |
{ | |
public IList<DeveloperDTO> developers { get; set; } | |
} | |
} |
<connectionStrings> | |
<add name="ApplicationServices" | |
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" | |
providerName="System.Data.SqlClient" /> | |
<add name="MongoHQ" | |
connectionString="your mongo uri"/> | |
</connectionStrings> |
static MongoDatabase retreive_mongohq_db() | |
{ | |
return MongoServer.Create( | |
ConfigurationManager.ConnectionStrings["MongoHQ"].ConnectionString) | |
.GetDatabase("t2"); | |
} |