I love build ASP.NET MVC projects using C# for this reason I’m searching an inexpensive way for publish my web projects using PaaS approach. After this search I choose AppHarbor solution for host application but for storage I wanted to experiment a Nosql database because I like flexibility of schema feature and there are many free solutions in internet.
I found MongoLab a cloud MongoDB hosting that provide 240MB without costs. The main way for access to mongodb database on mongolab are rest api very simple to use, but I’m .net developer so I created a small library for manage database using only C# classes. I called it MongoLab-Rest-Client and I release it on GitHub (yes I wanted try also git
).
What can we do with MongoLab-Rest-Client? Today all crud operations on our entities.
Steps:
1) Sign up to http://mongolab.com
2) Get the apikey ( ex. 123456789012345678901234 )
3) Write code:
var client = new MRestClient( “mydb” );
client.Apikey = “12345678901234567890123″;
// store a new entity
var obj = new Product();
var result = client.Create( obj );
// make a query using criteria api
var criteria = new Criteria();
criteria.Add( Restriction.Or
.Add( Restriction.Eq( “Name”, “name1″ ) )
.Add( Restriction.Eq( “Name”, “name2″ ) ) )
.Add( Restriction.Lte( “Quantity”, 2 ) );
IList products = client.GetByCriteria( criteria );
Only easy C# code and without define a schema on database.



mar 12, 2012 @ 02:59:08
Hi Antonio, I like what you have done. I am trying to use your good work, but I don’t know what to use for Product. Can you email me or put the class on GitHub? Thanks
mar 12, 2012 @ 09:25:57
Hi, this project was born to get easily access to a mongolab repository from a generic client, in particular I’m using it for windows phone 7 project. You can find all sources on github at https://github.com/antdimot/MongoLab-Rest-Client. If you want more informations about implementations I can help you.