MongoLab Rest Client


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.

About these ads

2 pensieri su “MongoLab Rest Client

  1. 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

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...