The new Data Abstract 8 is out. So I’d like to highlight some of its features and the changes they imply.
Xamarin support changes
To start with, the Xamarin iOS and Android platforms are now supported via Data Abstract for the Portable Class Library. This means that there is no more separate Data Abstract for MonoAndroid or MonoTouch builds.
On the bright side, this means that both target platforms now share the same set of features and, due to the PCL support, development of code shared between iOS and Android targets becomes a little easier. There are, however, some caveats you should be aware of:
- Only DA LINQ data access is supported, DataSet support on the iOS side is not available anymore, so a data access code revamp is needed.
- Only the simple HTTP client channel is available in Data Abstract for PCL. While this might look restricting, it is still the best choice for apps targeting mobile devices operating with a potentially unstable connection. In such conditions, SuperHTTP has no considerable advantage over the simple HTTP client channel.
- Only asynchronous server calls are possible. While this is a must in the mobile world due to unpredictable network delays, it can be a real headache when the Begin/End asynchronous calls pattern is used, especially when several remote calls are chained in the same method. Luckily, starting this release, RemObjects SDK for .NET now provides support for async/await remote calls.
async/await remote calls
Old async code with callback methods and BeginOperation/EndOperation calls was hard to develop and maintain. Starting with the Summer 2014 release, RemObjects SDK now allows to call remote servers using code like:
var result = await service.SumAsync(1, 2);
Of course, the target platform also has to support await calls, so this feature is not supported for .NET 3.5 clients. For all other target platforms,_Intf code will contain method declarations like:
public interface ISampleService_Async : RemObjects.SDK.IROService_Async { System.IAsyncResult BeginSum(double a, double b, System.AsyncCallback @__Callback, object @__UserData); double EndSum(System.IAsyncResult @__AsyncResult); System.Threading.Tasks.Task
Note the last method declaration. It is the asynchronous server call proxy that can be called using the async/await pattern.
Unfortunately, it is not possible to expand the DataAdapter class with …Async methods due to the necessity to support .NET 3.5. Instead, a set of extension methods was introduced that provide nearly the same experience.
These extension methods are defined in the assembly RemObjects.DataAbstract.Async.dll. For platforms that support Extension SDK packages (f.e. Windows Phone) this assembly is included in the Data Abstract packages. On other platforms (f.e. desktop .NET) this assembly has to be referenced explicitly.
Note that to call an extension method, you need to add the namespace this method is declared in to the using (C#)/Imports (VB.NET) or uses (Oxygene) clause.
The following extension methods are provided:
- IBaseLoginService_Async interface, methods are declared in the RemObjects.DataAbstract namespace.- Boolean LoginExAsync(String)
- LogoutAsync()
- DataAdapter (including LocalDataAdapter and RemoteDataAdapter), methods are declared in the RemObjects.DataAbstract namespace. All methods are awaitable versions of corresponding synchronous DataAdapter methods.- FillAsync(DataSet, Boolean)
- FillAsync(DataSet, Boolean, Boolean)
- FillAsync(DataSet, String[], Boolean)
- FillAsync(DataSet, String[], WhereExpression[], Boolean)
- FillAsync(DataSet, String[],TableRequestInfo[], Boolean)
- FillAsync(DataTable, WhereExpression, Boolean)
- FillAsync(DataTable,TableRequestInfo, Boolean)
- FillWithDASqlAsync(DataTable, String, DataParameter[])
- UpdateAsync(DataSet)
- UpdateAsync(DataSet, String[])
- UpdateAsync(Delta[], Boolean)
- LinqDataAdapter (including LocalLinqDataAdapter and RemoteLinqDataAdapter), methods are declared in the RemObjects.DataAbstract.Linq namespace.- LoadListAsync
(IQueryable – asynchronously loads data into List) - LoadBindableListAsync
(IQueryable – asynchronously loads data into BindingList) - ApplyChangesAsync()
Asynchronous data loading using one of these methods will look like
var list = await fDataAdapter.LoadListAsync( from x in fDataAdapter.GetTable
Windows Phone Applications support
This application type has a somewhat misleading name. Microsoft has renamed the good old Windows Phone apps based on Silverlight to Windows Phone Silverlight applications and introduced new WinRT based phone applications as Windows Phone. We register Data Abstract and RemObjects SDK as Extension SDKs for both these platforms. In case you want to reference Data Abstract assemblies directly, you need to reference assemblies from the WindowsPhone folder for Silverlight based applications and assemblies from the WinRT folder for Windows Phone Store applications. It is strongly recommended to use the ExtensionSDKs’ references instead of direct assembly references to avoid situations where wrong assemblies are referenced and the application just cannot be built.
That’s all for now. See you around and don’t forget to check the Breaking Changes page!