The document discusses using Microsoft SQL Server Compact (SQL CE) as a local database for mobile applications. SQL CE is a compact relational database produced by Microsoft that can be used to store relational data in a local database on Windows Phone devices. The document provides an overview of creating and maintaining a local SQL CE database in a Windows Phone application, including creating the database, performing queries with LINQ, inserting, updating and deleting data. It also discusses some tools for working with local SQL CE databases.
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Using SQL Local Database in Mobile Applications
1. Using SQL Local Database in
Mobile Applications
Microsoft SQL Server Compact (SQL CE) is a
compact relational database produced by Microsoft
for applications that run on mobile devices and
desktops.
With Windows Phone OS you can store relational
data in a local database.
2. About me
Mihail Mateev is a Senior Technical
Evangelist, Team Lead at Infragistics Inc.
Mihail worked in various areas related to
technology Microsoft: Silverlight, WPF,
Windows Phone 7, Visual Studio LightSwitch,
WCF RIA Services, ASP.Net MVC, Windows
Metro Applications, MS SQL Server and
Windows Azure
2 |
3. Agenda
Windows Phone
Windows Phone Mango Local Database(SQL CE)
Local Database Maintenance
Creating the Database
Database Queries with LINQ
Inserting Data
Updating Data
Deleting Data
Local Database Tools
SQL Compact Code Generator
CompactView
Isolated Storage Explorer
3 |
4. Windows Phone Platform
Goals
Simple End User
Personalization
Enable Cloud
Experiences
Help Developers be
Profitable
4 |
5. Windows Phone Application Platforms
Silverlight XNA
Vector XAML Graphics Fast 3D Graphics
Rich Media Engine
Rich Video 2D Sprites
Visual Studio Good Tooling
Tooling
5 |
6. Local Database for Windows Phone
With Windows Phone
OS 7.1, you can store
relational data in a
local database that
resides in your
application’s isolated
storage container.
6 |
7. Local Database for Windows Phone
Good to know
Isolated storage is used to store database files
LINQ to SQL is used as the ORM engine
LINQ is used to query data
Only System.Data.Linq assembly must be added
to the project
7 |
8. Local Database for Windows Phone
Limitations
ADO.NET objects are not supported
Skip() and Take() require an ordered list and
constant types
Only Microsoft SQL CE data types are supported
BinaryFormatter is not supported by default
ExcecuteCommand is not supported – NO T-
SQL, NO DML statement, NO DDL
8 |
9. Local Database vs. SQL Server
A local database runs in the Windows Phone
application’s process. Unlike a client-server database
such as Microsoft SQL Server, it does not run
continuously as a background service.
A local database can be accessed only by the
corresponding Windows Phone application. Because
the database file resides in isolated storage, no other
applications can access that data.
A local database can be accessed only with LINQ to
SQL; Transact-SQL is not supported.
9 |
10. Local Database Maintenance
Creating the Database
Database Queries with LINQ
Inserting Data
Updating Data
Deleting Data
10 |
11. Local Database(SQL CE):
Connection Strings
A special format of private const string ConnectionString =
@"isostore:/CountryDB.sdf";
the connection string
public MainPage()
must be used like for {
example: InitializeComponent();
"Data using (CountryDataContext context = new
Source='isostore:/DIRE CountryDataContext(ConnectionString))
{
CTORY/FILE.sdf'"
if (!context.DatabaseExists())
{
// create database if it does not exist
context.CreateDatabase();
}
}
}
11 |
12. Data Context
It inherits from the "System.Data.Linq.DataContext"
class
The data context constructor must call the
base(connectionString) constructor
The data context exposes the tables from the database
through properties of type Table<TEntity>. The Table
class implements IQueriable<TEntity> and enables you
to write LINQ queries against the database.
12 |
13. Creating a Local Database
using (CountryDataContext
After you create the context = new
DataContext CountryDataContext(ConnectionS
tring))
object, you can create {
the local database
if (!context.DatabaseExists())
and perform a {
number of additional // create database if it
does not exist
database operations. context.CreateDatabase();
}
}
13 |
14. Creating a Local Database
CountryDataContext is implemented in the
following way:
14 |
20. Local Database Tools
SQL Compact Code Generator
CompactView
Isolated Storage Explorer
20 |
21. SQL Server Compact Toolbox
SQL Server Compact
Toolbox is a Visual Studio
2010 Pro or higher add-in
(for 3.5/4.0) and standalone
app (for 4.0), that adds
scripting, import, export, mig
rate, rename, run
script, manage replication
and more to your SQL
Server Compact Data
Connections in VS Server
http://sqlcetoolbox.codeplex.com/
Explorer.
21 |
22. CompactView
CompactView is a
viewer for Microsoft®
SQL Server® Compact
Edition (SQLCE)
database files (*.sdf).
CompactView can open
database files of versions
3.1, 3.5 and 4.0.
http://sourceforge.net/p/compactview/home/Home/
22 |
23. Isolated Storage Explorer
Add-In for Visual Import data from
Studio 2010 to Isolated Storage
import, export or Export data to
modify data from the Isolated Storage
isolated storage of the automatic retrieval of
phone or the emulator the target (emulator /
Windows Phone phone) and the
identifier of the
current project
23 |