Getting Started with Xamarin



This guide shows how to set up the CData Xamarin Providers in Xamarin Studio and Visual Studio. The Xamarin providers enable you to use standard ADO.NET objects to work with disparate data sources. The code examples show how to install any Xamarin provider and write basic data access code.

Install the Provider

The provider is packaged as a Xamarin Component package (.xam), which can installed from the Xamarin Component Store. To manually install the .xam first download the xamarin-component tool provided by Xamarin.

On Windows, run the command below (Salesforce is used as an example):

xamarin-component.exe install CData.Salesforce-15.0.xam

In OS X, run the following command (again using Salesforce):

mono xamarin-component.exe install CData.Salesforce-15.0.xam

Add the Provider to Your Project

After successfully installing the package the provider is now accessible from Xamarin Studio and Visual Studio. To add the provider to a project in Xamarin Studio, follow the steps below:

  1. In your project right-click on Components and choose Edit Components.
  2. Click Add to Project to add the component to your package.
The provider will now be visible in the "Components" list and is ready to be used in your code.

Execute Queries

The following code examples show how to use ADO.NET objects to execute basic data access queries:

Retrieve Data

Execute a SELECT query to retrieve data. You can use DataReader and DataAdapter objects to execute SELECT queries. The example below shows how to use the SalesforceDataAdapter to fill a DataTable with the results of a query:

table = new DataTable();
SalesforceDataAdapter adapter = new SalesforceDataAdapter ("SELECT * FROM Account WHERE Industry='Floppy Disks'", conn);
adapter.Fill(table);

Insert, Update, and Delete

To execute data manipulation queries, you can write code like the example below:

SalesforceCommand command = conn.CreateCommand();
command.CommandText = "UPDATE Account SET Name = 'John Doe'";
return command.ExecuteNonQuery();
Open any of the sample projects for details on how to perform basic data access in Xamarin applications. In the help documentation, you can find more data source–specific information, including tutorials on using the Xamarin provider with Entity Framework and LINQ.
 
 
Downloads