This repository was archived by the owner on Dec 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Examples
ccellar edited this page Feb 11, 2013
·
3 revisions
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.
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);
}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);
}using (IDataContext context = new MiteDataContext(miteConfiguration))
{
Customer customer = context.GetById<Customer>(2345);
customer.Note = "sample note";
context.Update(customer);
}