SlideShare a Scribd company logo
1 of 27
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.
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 |
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 |
Windows Phone Platform

  Goals
  Simple End User
   Personalization
  Enable Cloud
   Experiences
  Help Developers be
   Profitable



4 |
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 |
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 |
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 |
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 |
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 |
Local Database Maintenance

      Creating the Database
      Database Queries with LINQ
      Inserting Data
      Updating Data
      Deleting Data




10 |
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 |
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 |
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 |
Creating a Local Database

   CountryDataContext is implemented in the
    following way:




14 |
Database Queries with LINQ




15 |
Inserting Data




16 |
Inserting Data




17 |
Updating Data




18 |
Deleting Data




19 |
Local Database Tools

   SQL Compact Code Generator
   CompactView
   Isolated Storage Explorer




20 |
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 |
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 |
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 |
Isolated Storage Explorer




       http://istool.codeplex.com/


24 |
DEMO
QUESTIONS



              Q&A



26 |
Sponsors

More Related Content

What's hot

Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
Niit Care
 
Introducing ms sql_server_updated
Introducing ms sql_server_updatedIntroducing ms sql_server_updated
Introducing ms sql_server_updated
leetinhf
 
Database application and design
Database application and designDatabase application and design
Database application and design
sieedah
 
Ado.net session10
Ado.net session10Ado.net session10
Ado.net session10
Niit Care
 

What's hot (20)

Sqllite
SqlliteSqllite
Sqllite
 
Discover database
Discover databaseDiscover database
Discover database
 
Sap webi chart creation from table
Sap webi chart creation from tableSap webi chart creation from table
Sap webi chart creation from table
 
Ado.net
Ado.netAdo.net
Ado.net
 
JAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and RetrievalJAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and Retrieval
 
SQL Training Institute in Ambala ! Batra Computer Centre
SQL Training Institute in Ambala ! Batra Computer CentreSQL Training Institute in Ambala ! Batra Computer Centre
SQL Training Institute in Ambala ! Batra Computer Centre
 
Performance Benchmarking of Key-Value Store NoSQL Databases
Performance Benchmarking of Key-Value Store NoSQL Databases Performance Benchmarking of Key-Value Store NoSQL Databases
Performance Benchmarking of Key-Value Store NoSQL Databases
 
Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
 
Introducing ms sql_server_updated
Introducing ms sql_server_updatedIntroducing ms sql_server_updated
Introducing ms sql_server_updated
 
Database application and design
Database application and designDatabase application and design
Database application and design
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 
Ado.net session10
Ado.net session10Ado.net session10
Ado.net session10
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
 
6. hibernate
6. hibernate6. hibernate
6. hibernate
 
Artigo no sql x relational
Artigo no sql x relationalArtigo no sql x relational
Artigo no sql x relational
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
A Survey of Non -Relational Databases with Big Data
A Survey of Non -Relational Databases with Big DataA Survey of Non -Relational Databases with Big Data
A Survey of Non -Relational Databases with Big Data
 
SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...
SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...
SSIS Tutorial For Beginners | SQL Server Integration Services (SSIS) | MSBI T...
 
Informatica training
Informatica trainingInformatica training
Informatica training
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
 

Similar to Using SQL Local Database in Mobile Applications

ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
Sonu Vishwakarma
 
Vb.net session 16
Vb.net session 16Vb.net session 16
Vb.net session 16
Niit Care
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
Niit Care
 
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
Christoph Adler
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
glubox
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soon
Richard Rabins
 
android sqlite
android sqliteandroid sqlite
android sqlite
Deepa Rani
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
ukdpe
 

Similar to Using SQL Local Database in Mobile Applications (20)

6 database
6 database 6 database
6 database
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Microsoft Azure Overview Infographic
Microsoft Azure Overview InfographicMicrosoft Azure Overview Infographic
Microsoft Azure Overview Infographic
 
Vb.net session 16
Vb.net session 16Vb.net session 16
Vb.net session 16
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
 
SQL Server Compact
SQL Server CompactSQL Server Compact
SQL Server Compact
 
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
ICS UserGroup - 2015 - Infrastructure Assessment - Analyze, Visualize and Opt...
 
05 entity framework
05 entity framework05 entity framework
05 entity framework
 
Ibi Open Visualizations
Ibi Open VisualizationsIbi Open Visualizations
Ibi Open Visualizations
 
Cdi implementation
Cdi implementationCdi implementation
Cdi implementation
 
Entity Framework V1 and V2
Entity Framework V1 and V2Entity Framework V1 and V2
Entity Framework V1 and V2
 
Iphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOSIphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOS
 
Project seminar
Project seminarProject seminar
Project seminar
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
5c8605.ado.net
5c8605.ado.net5c8605.ado.net
5c8605.ado.net
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soon
 
android sqlite
android sqliteandroid sqlite
android sqlite
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
 

More from Mihail Mateev

Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
Mihail Mateev
 
Spatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting ServicesSpatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting Services
Mihail Mateev
 

More from Mihail Mateev (7)

Dealing with Azure Cosmos DB
Dealing with Azure Cosmos DBDealing with Azure Cosmos DB
Dealing with Azure Cosmos DB
 
Clash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft AzureClash of Technologies Google Cloud vs Microsoft Azure
Clash of Technologies Google Cloud vs Microsoft Azure
 
Devday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_appDevday 2014 using_afs_in_your_cloud_app
Devday 2014 using_afs_in_your_cloud_app
 
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
Cloud conf-varna-2014-mihail mateev-spatial-data-and-microsoft-azure-sql-data...
 
Varna conf nodejs-oss-microsoft-azure[final]
Varna conf nodejs-oss-microsoft-azure[final]Varna conf nodejs-oss-microsoft-azure[final]
Varna conf nodejs-oss-microsoft-azure[final]
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
 
Spatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting ServicesSpatial Data with SQL Server Reporting Services
Spatial Data with SQL Server Reporting Services
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+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 |
  • 24. Isolated Storage Explorer http://istool.codeplex.com/ 24 |
  • 25. DEMO
  • 26. QUESTIONS Q&A 26 |