Skip to content
This repository was archived by the owner on Dec 25, 2020. It is now read-only.

Examples

ccellar edited this page Feb 11, 2013 · 3 revisions

Configuration

The mite data context needs to be configurated with your mite domain and your credentials or api key. You can explicitly set the values or use the app.config or web.config.

var miteConfiguration = new MiteConfiguration(new Uri("https://{account}.mite.yo.lk"), "{api key}"); 

or with user and password

var miteConfiguration = new MiteConfiguration(new Uri("https://{account}.mite.yo.lk"), "{user}", {password}); 

If you don't pass parameters to the constructor it will read the config from the config file.

Creating items

For interaction with mite you first have to create an instance of the mite data context

using (IDataContext context = new MiteDataContext(miteConfiguration))
{
 Customer customer = new Customer();
 customer.Name = "Test";

 customer = context.Create(customer);
}

Get items

using (IDataContext context = new MiteDataContext(miteConfiguration))
{
 IList<Customer> customers = context.GetAll<Customer>();
}

To retrieve a single record

using (IDataContext context = new MiteDataContext(miteConfiguration))
{
 Customer customer = context.GetById<Customer>(2345);
}

Updating items

using (IDataContext context = new MiteDataContext(miteConfiguration))
{
 Customer customer = context.GetById<Customer>(2345);
 customer.Note = "sample note";
 context.Update(customer);
}

Clone this wiki locally