Learn more about Telerik Everlive here
To start with and put in a single sentence Telerik Everlive in Backend as a Service offering from Telerik. In this post we will take a look on fetching data from Everlive in a .Net application. We will consider using .Net Console Application. However concept will be same for almost all other kind of .Net applications like WPF, Windows Apps.
To start with download .NET SDK from here . On download page make sure that you have selected .NET platform. Download and extract folder. You should get two dll. You need to add these dll in .Net project.
To add dll in project right click on Reference in project. From context menu select option of Add Reference. You need to add above two extracted dll in the project.
After adding required references next step is to create class which will represent Everlive content type in the client application. That class can be created as following ,
public class Products : DataItem { private string productName; public string ProductName { get { return this.productName; } set { this.productName = value; this.OnPropertyChanged("ProductName"); } } private int unitPrice; public int UnitPrice { get { return this.unitPrice; } set { this.unitPrice = value; this.OnPropertyChanged("UnitPrice"); } } private int quantity; public int Quantity { get { return this.quantity; } set { this.quantity = value; this.OnPropertyChanged("Quantity"); } } private bool isContinued; public bool IsContinued { get { return this.isContinued; } set { this.isContinued = value; this.OnPropertyChanged("IsContinued"); } } private int unitInStock; public int UnitInStock { get { return this.unitInStock; } set { this.unitInStock = value; this.OnPropertyChanged("UnitInStock"); } } }
There are couple of points you need to keep in mind,
- Class name should be same as Content Type name
- Class should inherit from DataItem. It is not a must condition though.
- Properties name should be same as columns of Content Type
After creating client side class, you can either synchronously or asynchronously fetch items from Everlive. Items can be fetched asynchronously as below,
static async void FetchData(EverliveApp productApp) { var products = await productApp.WorkWith().Data<Products>().GetAll().ExecuteAsync(); foreach (var item in products) { Console.WriteLine(item.ProductName + item.UnitPrice); } }
Important point is that you need to pass client side type (class) in this case Product to fetch items. You need to make an instance of EverliveApp class passing your app key in the constructor.
static void Main(string[] args) { EverliveApp productApp = new EverliveApp("yourkey"); FetchData(productApp); Console.ReadKey(true); }
This is all you need to do to fetch elements from Telerik Eeverlive in a .Net Console Application. I hope you like this post. Thanks for reading.
Pingback: How to CRUD operation on Telerik Everlive data from .NET Application | Telerik Helper