WI005 - Offline data sync con SQLite in Universal Windows Platform



Similar documents
Cloud Powered Mobile Apps with Azure

Getting Started with Telerik Data Access. Contents

Beginning C# 5.0. Databases. Vidya Vrat Agarwal. Second Edition

MS 10978A Introduction to Azure for Developers

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

v1.1.0 SimpleSQL SQLite manager for Unity3D echo17.com

Course 10978A Introduction to Azure for Developers

Financial Data Access with SQL, Excel & VBA

Cloud Powered Mobile Apps with Microsoft Azure

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

SQL Server An Overview

Identity + Mobile Management + Security = Enterprise Mobility Suite

Introduction to Azure for Developers

Creating Reports Crystal Clear

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Application Development

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Using SQL Server Management Studio

C++ Wrapper Library for Firebird Embedded SQL

Discovering SQL. Wiley Publishing, Inc. A HANDS-ON GUIDE FOR BEGINNERS. Alex Kriegel WILEY

MS ACCESS DATABASE DATA TYPES

Database Administration with MySQL

Developing Mapping Applications with ArcGIS Runtime SDK for Windows Mobile. Jay Chen Justin Colville

Visual basic string search function, download source code visual basic 6.0 gratis. > Visit Now <

Oracle Database 10g Express

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Object Relational Database Mapping. Alex Boughton Spring 2011

Tips & Tricks for Using Key Windows Vista Native APIs from Managed Code

10978A: Introduction to Azure for Developers

Deploying Management and Security Agents to Mobile Devices. Deploying Mgmt and Security Agents

Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA)

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA

SQL Injection. Blossom Hands-on exercises for computer forensics and security

Introduction to Building Windows Store Apps with Windows Azure Mobile Services

Microsoft Introduction to Azure for Developers

SSRS Reporting Using Report Builder 3.0. By Laura Rogers Senior SharePoint Consultant Rackspace Hosting

Accessing External Databases from Mobile Applications

Database Systems. S. Adams. Dilbert. Available: Hans-Petter Halvorsen, M.Sc.

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

Choosing the right Mobile BI tool: SSRS vs Power BI vs Datazen

SQL Server 2016 BI Any Data, Anytime, Anywhere. Phua Chiu Kiang PCK CONSULTING MVP (Data Platform)

SQL Server Database Coding Standards and Guidelines

MOC 20461C: Querying Microsoft SQL Server. Course Overview

AppDev OnDemand Cloud Computing Learning Library

Commercial Database Software Development- A review.

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

sqlite driver manual

Introduction to SQL and database objects

Introduction to SQL for Data Scientists

Databases and SQL. The Bioinformatics Lab SS Wiki topic 10. Tikira Temu. 04. June 2013

Rhomobile cross-platfrom

A basic create statement for a simple student table would look like the following.

Develop your Database using Database Projects from SQL Server Data Tools (SSDT)

QML and JavaScript for Native App Development

Introduction to Database. Systems HANS- PETTER HALVORSEN,

The power of root on Android emulators

UniFinger Engine SDK Manual (sample) Version 3.0.0

Creating and Using Databases for Android Applications

ITG Software Engineering

ArcGIS Web Mapping. Sam Berg, esri

CSCC09F Programming on the Web. Mongo DB

Database Migration from MySQL to RDM Server

Developing Microsoft SharePoint Server 2013 Core Solutions

ESET Secure Authentication Java SDK

ASP.NET Programming with C# and SQL Server

Database Design Patterns. Winter Lecture 24

Microsoft SQL Server to Infobright Database Migration Guide

CRM Magic with Data Migration & Integration

PEGA MOBILITY A PEGA PLATFORM WHITEPAPER

How To Create A Table In Sql (Ahem)

How To Guide: Windows App Development using SAP Mobile Platform SDK 3.0 for Windows 8.1

Intro to Databases. ACM Webmonkeys 2011

Chapter 30 Exporting Inventory Management System Data

Advanced SQL. Jim Mason. Web solutions for iseries engineer, build, deploy, support, train

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

EXAM PRO:Design & Develop Windows Apps Using MS.NET Frmwk 4. Buy Full Product.

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Short notes on webpage programming languages

Information Technology NVEQ Level 2 Class X IT207-NQ2012-Database Development (Basic) Student s Handbook

Guide to Upsizing from Access to SQL Server

Embedded SQL programming

Real-time reporting at 10,000 inserts per second. Wesley Biggs CTO 25 October 2011 Percona Live

ODBC Client Driver Help Kepware, Inc.

Connecting Software Connect Bridge - Mobile CRM Android User Manual

SimbaEngine SDK 9.4. Build a C++ ODBC Driver for SQL-Based Data Sources in 5 Days. Last Revised: October Simba Technologies Inc.

SQL - QUICK GUIDE. Allows users to access data in relational database management systems.

HTSQL is a comprehensive navigational query language for relational databases.

Enabling development teams to move fast. PostgreSQL at Zalando

ADOBE AIR. Working with Data in AIR. David Tucker

Developing Exceptional Mobile and Multi-Channel Applications using IBM Web Experience Factory IBM Corporation 1

IBM Campaign Version-independent Integration with IBM Engage Version 1 Release 3 April 8, Integration Guide IBM

KPiSync. By Larry McGhaw, Chief Technology Officer

Transcription:

WI005 - Offline data sync con SQLite in Universal Windows Platform presenta Erica Barone Microsoft Technical Evangelist @_ericabarone erbarone@microsoft.com Massimo Bonanni Microsoft MVP, Intel Black Belt Intel Software Innovator @massimobonanni massimo.bonanni@tiscali.it www.wpc2015.it info@wpc2015.it - +39 02 365738.11 - #wpc15it 1

Agenda SQLite UWP What is/isn t SQLite SQLite for UWP.NET APIs SQLite.NET-PCL vs SQLitePCL Tools Offline Data sync Mobile App SyncAsync PCL www.wpc2015.it info@wpc2015.it - +39 02 365738.11 2

What is SQLite? Open source RDBMS. Works as library instead of service (in-process) Single file database. Triggers Tables Indices Views Cross Platform database (Mac, Windows, Linux). Cross Technology Database (WPF, UWP, Win Form). Implements most of the SQL standard (SQL92). RIGHT and FULL OUTER JOIN Only the RENAME TABLE and ADD COLUMN variants of the ALTER TABLE VIEWs in SQLite are read-only. Zero-configuration www.wpc2015.it info@wpc2015.it - +39 02 365738.11 - #wpc15it 3

What isn t SQLite? Not a full database application No forms No reports No saved queries www.wpc2015.it info@wpc2015.it - +39 02 365738.11 4

SQLite for Universal App Platform Contains an extension SDK and all other components needed to use SQLite for UAP application development with Visual Studio 2015. Visual Studio Extension (.vsix) Install from Visual Studio (Tools Extensions and Updates ) Or download from SQLite.org www.wpc2015.it info@wpc2015.it - +39 02 365738.11 5

.NET APIs SQLite.NET-PCL LINQ syntax Lightweight ORM (no navigation properties) SQLitePCL SQL statements (ADO Style) Thin wrapper around the SQLite C API From Microsoft Open Technologies www.wpc2015.it info@wpc2015.it - +39 02 365738.11 6

SQLite.NET-PCL var conn = new SQLiteConnection(new Platform.WinRT.SQLitePlatformWinRT(), dbname); conn.createtable<libro>(); SQLitePCL Create a database [Table("Libri")] public class Libro : ILibro [PrimaryKey, AutoIncrement] public long Id get; set; [MaxLength(100)] public string Titolo get; set; [MaxLength(255)] public string Abstract get; set; [MaxLength(13)] public string ISBN get; set; public long Pagine get; set; public byte[] Copertina get; set; public long IdAutore get; set; public IAutore Autore get; set; public ICollection<IRecensione> Recensioni get; set; var conn = new SQLiteConnection(dbName); sql = @"CREATE TABLE IF NOT EXISTS [Libri]( [Id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, [Titolo] VARCHAR(100) NOT NULL, [Abstract] VARCHAR(255), [ISBN] CHAR(13), [Pagine] SMALLINT, [Copertina] IMAGE, [IdAutore] INTEGER NOT NULL, CONSTRAINT [Autiri_Libri] FOREIGN KEY([IdAutore]) REFERENCES Autori([Id]));"; using (var statement = conn.prepare(sql)) statement.step(); www.wpc2015.it info@wpc2015.it - +39 02 365738.11 7

SQLite.NET-PCL Query No Navigation Properties var libri = DB.Table<Libro>().Where(l => l.idautore == idautore) SQLitePCL using (var dbconn = new SQLiteConnection(DatabaseName)) using (var statement = dbconn.prepare(@"select [Libri].[Titolo], [Libri].[Id] as IdLibro, [Libri].[Abstract], [Libri].[ISBN], [Libri].[Pagine], [Libri].[Copertina], [Libri].[IdAutore], [Autori].[Cognome], [Autori].[Nome] FROM [Libri] INNER JOIN [Autori] ON [Autori].[Id] = [Libri].[IdAutore]")) while (SQLiteResult.ROW == statement.step()) retlist.add(mapper.map<isqlitestatement, Libro>(statement)); www.wpc2015.it info@wpc2015.it - +39 02 365738.11 8

SQLite.NET-PCL CRUD Operations DB.Insert(entity, typeof(libro)) SQLitePCL using (var dbconn = new SQLiteConnection(DatabaseName)) using (var statement = dbconn.prepare(@"insert INTO [Libri] ([Titolo],[Abstract],[ISBN],[Pagine],[Copertina],[IdAutore]) VALUES (@Titolo,@Abstract,@ISBN,@Pagine,@Copertina,@IdAutore)")) statement.bind("@titolo", entity.titolo); statement.bind("@abstract", entity.abstract); statement.bind("@isbn", entity.isbn); statement.bind("@pagine", entity.pagine); statement.bind("@copertina", entity.copertina); statement.bind("@idautore", entity.idautore); result = SQLiteResult.OK == statement.step(); www.wpc2015.it info@wpc2015.it - +39 02 365738.11 9

SQLite.NET-PCL Transactions DB.BeginTransaction(); // do something with Database if (/* something wrong */) DB.Rollback(); else DB.Commit(); SQLitePCL using (var dbconn = new SQLiteConnection(DatabaseName)) using (var statement = dbconn.prepare("begin TRANSACTION")) statement.step(); // Execute one or more statements... using (var lbrcommand = dbconn.prepare("insert INTO Libri (Titolo, Abstract, ISBN) VALUES (@Titolo, @Abstract, @ISBN)")) //... using (var reccommand = dbconn.prepare("insert INTO Recensioni (Testo, Voto, IdLibro) VALUES (@Testo, @Voto, @IdLibro)")) //... // COMMIT to accept all changes or ROLLBACK TRANSACTION to discard pending changes using (var statement = dbconn.prepare("commit TRANSACTION")) statement.step(); www.wpc2015.it info@wpc2015.it - +39 02 365738.11 10

Tools www.wpc2015.it info@wpc2015.it - +39 02 365738.11 11

DEMO Biblioteca SQLite www.wpc2015.it info@wpc2015.it - +39 02 365738.11 12

Sync your data on all devices

Demo overview Offline sync SQL DB User Authentication Mobile App VS 2015 Twitter provider Authentication UWP App

Mobile App

SyncAsync Every time the data change, the method SyncAsync must be called in order to update the SQL Database Push sends all CUD changes since the last push. Note that it is not possible to send only an individual table's changes. Push executes a series of REST calls to your Azure Mobile App backend, which in turn will modify your server database. Pull is performed on a per-table basis and can be customized with a query to retrieve only a subset of the server data. The Azure Mobile client SDKs then insert the resulting data into the local store.

Wrap your code into a PCL Offline sync SQL DB User Authentication Mobile App UWP App Authentication PCL Android App Twitter provider

UWP App running on PC - Android App running on Android Tablet

Q & A www.wpc2015.it info@wpc2015.it - +39 02 365738.11 - #wpc15it 21

OverNet Education info@overneteducation.it www.overneteducation.it Tel. 02 365738 Contatti OverNet Education @overnete www.facebook.com/overneteducation www.linkedin.com/company/overnet-solutions www.wpc2015.it www.wpc2015.it info@wpc2015.it - +39 02 365738.11 - #wpc15it 22