SlideShare une entreprise Scribd logo
1  sur  38
Windows Phone 7 Li Jingnan / Wang Tao 2011-7-15 1
2 days 2
ethos http://www.ethostechnologies.com/ One of the 1st ISVs for cloud computing in Europe and China. Cloud computing development partner with Microsoft in Greater China Region. Invited to speak about Azure at several Microsoft events.
about anytao| Ethos <ethos:Member    id = “Wang Tao”    msn = anytao@live.com weibo = http://weibo.com/anytao runat = “Senior System Architect” /> Jason | Ethos <ethos:Member    id = “Li Jingnan”    msn = zengnami@hotmail.com weibo= http://weibo.com/jn1981 runat = “SE” />
about http://book.anytao.net
10 Local Database Wang Tao / 2011-07-15
session outline LINQ to SQL LINQ to User Data overview architecture code-first development implementation details queries inserts, updates, deletes… database schema upgrades performance and best practices overview end-user consent supported account types implementation details querying contacts querying appointments performance and best practices
LINQ to everything LINQ Objects XML SQL User Data OData 7 Mango
complex schema numerous relationships and constraints example: shopping list 7 tables 100s of records 5 foreign keys
Reference Data Huge amounts of static reference data Example: dictionary app 3 tables 1 table with 500k rows
web service cache Cloud Service fetch reference data from cloud cache it locally combine with user-specific data Windows Phone Service Cache User Data
user data filter contacts birthdays in the next month query all appointments find an available time for a meeting Filter
database support
local data storage: overview apps store private data in Isolated Storage ,[object Object]
unstructured data in Isolated Storage files
structured data in database filesApp Root Folder Install Package Manager Creates root folder sandboxed to App DB Database File (r/o) App Data Folder Creates/Manages files and settings App WP7 Isolated Storage APIs DB Application Settings File Application Files Database file
architecture Your App Custom Data Context App Objects var query = fromw indb.Wines wherew.Country== “USA" selectw.Name; System.Data.Linq Identity Management Change Tracking Update Processing Object Materialization .Call System.Linq.Queryable.Select( .Call System.Linq.Queryable.Where( .Constant(Table(Wines)), '(.Lambda #Lambda1)), '(.Lambda #Lambda2)) .Lambda #Lambda1(db.Wines $w) { $w.Country== “USA" } .Lambda #Lambda2(w.Country $w) { $w.Name} select Name from Wines where Country = “USA” Microsoft.Phone.Data.Internal  Core ADO.NET (System.Data) SQL CE DB SQLCE ADO.NET Provider (System.Data.SqlServerCe)
code first development Design time ,[object Object]
Decorate objects with attributes for persistenceVarietals Wines Vineyards WineMakers ,[object Object]
Translate object model into a database file
Submit API persists changes to DBRun time Database upgrade ,[object Object]
Use upgrade APIs to change DB,[object Object]
queries: examples // Create the database form data context, using a connection string DataContextdb = newWineDataContext("isostore:/wineDB.sdf"); // Find all wines currently at home, ordered by date acquired varq = from w indb.Wines 	  wherew.Varietal.Name == “Shiraz” && w.IsAtHome == true orderbyw.DateAcquired 	  select w;
Inserts/Updates/Deletes Your App Code It’s all about the DataContext Changes made against the DataContext first Changes persisted by calling SubmitChanges() SubmitChanges LINQ to SQL determines change set and submits to DB DataContext DB
inserts/updates/deletes update insert WinenewWine= newWine { WineID= “1768", Name = “Windows Phone Syrah", Description = “Bold and spicy" }; db.Wines.InsertOnSubmit(newWine); db.SubmitChanges(); Winewine=  (fromw indb.Wines  wherew.WineID== “1768" select w).First(); wine.Description= “Hints of plum and melon"; db.SubmitChanges();
inserts/updates/deletes delete varvineyardsToDelete=  fromVineyards v in db.Vineyards wherev.Country== “Australia” select v; db.Vineyards.DeleteAllOnSubmit (vineyardsToDelete); db.SubmitChanges(); Foreign key constraint will cause exception here if Wines associated with the Vineyards are not deleted first
inserts/updates/deletes varvineyardsToDelete= fromVineyards v indb.Vineyards 			wherev.Country== “Australia" select v; foreach (Vineyards v invineyardsToDelete) { db.Wines.DeleteAllOnSubmit(v.Wines); } db.Vineyards.DeleteAllOnSubmit(vineyardsToDelete); db.SubmitChanges();
database schema upgrades DatabaseSchemaUpdater allows for simple upgrades on your existing DB It offers the ability to add Tables Columns Indices Associations/foreign keys All schema updates are transactional More complex schema upgrades require full DB migration
Database Schema Upgrades Create a new DatabaseSchemaUpdater MyDerivedDataContext context = newMyDerivedDataContext("foo.sdf");DatabaseSchemaUpdaterdbUpdater = context.CreateDatabaseSchemaUpdater(); Add a new table tied to the Product class dbUpdater.AddTable<Winemaker>(); Add a Region column to the Customer table dbUpdater.AddColumn<Vineyard>(“YearEstablished"); Execute upgrade dbUpdater.Execute();
performance and best practices keep change sets small Submit early and often to avoid data loss on app termination use background threads Non-trivial operations will impact app responsiveness if done on UI thread optimize read-only queries Set ObjectTrackingEnabled to minimize memory usage use secondary indices for properties which you query often
performance and best practices populate large reference data tables in advance Create a simple project to prepopulate data in emulator Pull out database file using Isolated Storage explorer when to use a database… expect some impact to startup time and memory usage from incorporating a DB stick to IsolatedStorageSettings or basic files for small data sets
user data
new and updated APIs in “Mango” Chooser Tasks related to user data EmailAddressChooserTask PhoneNumberChooserTask AddressChooserTask Microsoft.Phone.UserData for direct access Contacts Appointments
AddressChooserTask privateAddressChooserTaskaddressChooserTask; // Constructor publicMainPage() { this.addressChooserTask= newAddressChooserTask(); this.addressChooserTask.Completed += new EventHandler<AddressResult>( addressChooserTask_Completed); } privatevoidaddressChooserTask_Completed(objectsender, AddressResulte) { if(null == e.Error && TaskResult.OK == e.TaskResult)    { ... = e.DisplayName; ... = e.Address; } }
Microsoft.Phone.UserData Important points Contacts and Appointments APIs are read only Third party social network data cannot be shared
Contacts/Appointments Data Shared
contacts: hello, world! Contactscontacts = newContacts(); contacts.SearchCompleted+= newEventHandler<ContactsSearchEventArgs>((sender, e) =>             { ...= e.Results;             }); // E.g. search for all contacts contacts.SearchAsync(string.Empty, FilterKind.None, null); state // E.g. search for all contacts with display name matching "ja" contacts.SearchAsync("ja", FilterKind.DisplayName, null); filter expression (not a regex) Filter kind: name, email , phone or pinned to start)
appointments: hello, world! Appointmentsappointments = newAppointments(); appointments.SearchCompleted+= newEventHandler<AppointmentsSearchEventArgs>((sender, e) =>             { ... = e.Results;             }); // E.g. get next appointment (up to 1 week away) appointments.SearchAsync(DateTime.Now, DateTime.Now+ TimeSpan.FromDays(7),                         1, null); start date and time end date and time Maximum items to return state

Contenu connexe

En vedette

Windows Phone 7 in azure
Windows Phone 7 in azureWindows Phone 7 in azure
Windows Phone 7 in azureTao Wang
 
09 wp7 multitasking
09 wp7   multitasking09 wp7   multitasking
09 wp7 multitaskingTao Wang
 
12 wp7 marketing windows phone applications
12 wp7   marketing windows phone applications12 wp7   marketing windows phone applications
12 wp7 marketing windows phone applicationsTao Wang
 
11 wp7 designing applicationsusingexpressionblend
11 wp7   designing applicationsusingexpressionblend11 wp7   designing applicationsusingexpressionblend
11 wp7 designing applicationsusingexpressionblendTao Wang
 
Anytao 让windows phone应用在云端翱翔
Anytao 让windows phone应用在云端翱翔Anytao 让windows phone应用在云端翱翔
Anytao 让windows phone应用在云端翱翔Tao Wang
 
13 wp7 working with azure
13 wp7   working with azure13 wp7   working with azure
13 wp7 working with azureTao Wang
 
01 windows azure platform overview
01 windows azure platform overview01 windows azure platform overview
01 windows azure platform overviewTao Wang
 

En vedette (8)

Windows Phone 7 in azure
Windows Phone 7 in azureWindows Phone 7 in azure
Windows Phone 7 in azure
 
09 wp7 multitasking
09 wp7   multitasking09 wp7   multitasking
09 wp7 multitasking
 
12 wp7 marketing windows phone applications
12 wp7   marketing windows phone applications12 wp7   marketing windows phone applications
12 wp7 marketing windows phone applications
 
11 wp7 designing applicationsusingexpressionblend
11 wp7   designing applicationsusingexpressionblend11 wp7   designing applicationsusingexpressionblend
11 wp7 designing applicationsusingexpressionblend
 
Anytao 让windows phone应用在云端翱翔
Anytao 让windows phone应用在云端翱翔Anytao 让windows phone应用在云端翱翔
Anytao 让windows phone应用在云端翱翔
 
13 wp7 working with azure
13 wp7   working with azure13 wp7   working with azure
13 wp7 working with azure
 
01 windows azure platform overview
01 windows azure platform overview01 windows azure platform overview
01 windows azure platform overview
 
Windows Azure Platform Overview
Windows Azure Platform OverviewWindows Azure Platform Overview
Windows Azure Platform Overview
 

Similaire à 10 wp7 local database

Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Servicesukdpe
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?ukdpe
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRPeter Elst
 
Web Deployment With Visual Studio 2010
Web Deployment With Visual Studio 2010Web Deployment With Visual Studio 2010
Web Deployment With Visual Studio 2010Rishu Mehra
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발영욱 김
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter Elst
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2Jim Driscoll
 
Evolutionary db development
Evolutionary db development Evolutionary db development
Evolutionary db development Open Party
 
Silverlight 5 whats new overview
Silverlight 5 whats new overviewSilverlight 5 whats new overview
Silverlight 5 whats new overviewmdc11
 
IE8 Dev Overview_pp2003
IE8 Dev Overview_pp2003IE8 Dev Overview_pp2003
IE8 Dev Overview_pp2003Wes Yanaga
 
Windows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseWindows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseOliver Scheer
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!Sébastien Levert
 
Getting Started with Iron Speed Designer
Getting Started with Iron Speed DesignerGetting Started with Iron Speed Designer
Getting Started with Iron Speed DesignerIron Speed
 

Similaire à 10 wp7 local database (20)

Windows Azure and a little SQL Data Services
Windows Azure and a little SQL Data ServicesWindows Azure and a little SQL Data Services
Windows Azure and a little SQL Data Services
 
What's New for Data?
What's New for Data?What's New for Data?
What's New for Data?
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
Web Deployment With Visual Studio 2010
Web Deployment With Visual Studio 2010Web Deployment With Visual Studio 2010
Web Deployment With Visual Studio 2010
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Practical OData
Practical ODataPractical OData
Practical OData
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
PPT
PPTPPT
PPT
 
Evolutionary db development
Evolutionary db development Evolutionary db development
Evolutionary db development
 
Silverlight 5 whats new overview
Silverlight 5 whats new overviewSilverlight 5 whats new overview
Silverlight 5 whats new overview
 
IE8 Dev Overview_pp2003
IE8 Dev Overview_pp2003IE8 Dev Overview_pp2003
IE8 Dev Overview_pp2003
 
Windows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local DatabaseWindows Phone 8 - 7 Local Database
Windows Phone 8 - 7 Local Database
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
Getting Started with Iron Speed Designer
Getting Started with Iron Speed DesignerGetting Started with Iron Speed Designer
Getting Started with Iron Speed Designer
 
B_110500002
B_110500002B_110500002
B_110500002
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Plus de Tao Wang

团队高效沟通的秘密
团队高效沟通的秘密团队高效沟通的秘密
团队高效沟通的秘密Tao Wang
 
高效团队的秘密
高效团队的秘密高效团队的秘密
高效团队的秘密Tao Wang
 
Worktile 更好用的企业协作平台
Worktile   更好用的企业协作平台Worktile   更好用的企业协作平台
Worktile 更好用的企业协作平台Tao Wang
 
Hello, Worktile Pro
Hello, Worktile ProHello, Worktile Pro
Hello, Worktile ProTao Wang
 
08 wp7 push notification
08 wp7   push notification08 wp7   push notification
08 wp7 push notificationTao Wang
 
08 wp7 push notification
08 wp7   push notification08 wp7   push notification
08 wp7 push notificationTao Wang
 
07 wp7 application lifecycle
07 wp7   application lifecycle07 wp7   application lifecycle
07 wp7 application lifecycleTao Wang
 
06 wp7 isolation storage
06 wp7   isolation storage06 wp7   isolation storage
06 wp7 isolation storageTao Wang
 
03 wp7 application bar
03 wp7   application bar03 wp7   application bar
03 wp7 application barTao Wang
 
03 wp7 application bar
03 wp7   application bar03 wp7   application bar
03 wp7 application barTao Wang
 
05 wp7 launchers and choosers
05 wp7   launchers and choosers05 wp7   launchers and choosers
05 wp7 launchers and choosersTao Wang
 
04 wp7 pivot and panorama
04 wp7   pivot and panorama04 wp7   pivot and panorama
04 wp7 pivot and panoramaTao Wang
 
02 wp7 building silverlight applications
02 wp7   building silverlight applications02 wp7   building silverlight applications
02 wp7 building silverlight applicationsTao Wang
 
01 wp7 introduction
01 wp7   introduction01 wp7   introduction
01 wp7 introductionTao Wang
 
Azure 迁移之道
Azure 迁移之道Azure 迁移之道
Azure 迁移之道Tao Wang
 
Facebook and its development
Facebook and its developmentFacebook and its development
Facebook and its developmentTao Wang
 
What is silverlight?
What is silverlight?What is silverlight?
What is silverlight?Tao Wang
 

Plus de Tao Wang (17)

团队高效沟通的秘密
团队高效沟通的秘密团队高效沟通的秘密
团队高效沟通的秘密
 
高效团队的秘密
高效团队的秘密高效团队的秘密
高效团队的秘密
 
Worktile 更好用的企业协作平台
Worktile   更好用的企业协作平台Worktile   更好用的企业协作平台
Worktile 更好用的企业协作平台
 
Hello, Worktile Pro
Hello, Worktile ProHello, Worktile Pro
Hello, Worktile Pro
 
08 wp7 push notification
08 wp7   push notification08 wp7   push notification
08 wp7 push notification
 
08 wp7 push notification
08 wp7   push notification08 wp7   push notification
08 wp7 push notification
 
07 wp7 application lifecycle
07 wp7   application lifecycle07 wp7   application lifecycle
07 wp7 application lifecycle
 
06 wp7 isolation storage
06 wp7   isolation storage06 wp7   isolation storage
06 wp7 isolation storage
 
03 wp7 application bar
03 wp7   application bar03 wp7   application bar
03 wp7 application bar
 
03 wp7 application bar
03 wp7   application bar03 wp7   application bar
03 wp7 application bar
 
05 wp7 launchers and choosers
05 wp7   launchers and choosers05 wp7   launchers and choosers
05 wp7 launchers and choosers
 
04 wp7 pivot and panorama
04 wp7   pivot and panorama04 wp7   pivot and panorama
04 wp7 pivot and panorama
 
02 wp7 building silverlight applications
02 wp7   building silverlight applications02 wp7   building silverlight applications
02 wp7 building silverlight applications
 
01 wp7 introduction
01 wp7   introduction01 wp7   introduction
01 wp7 introduction
 
Azure 迁移之道
Azure 迁移之道Azure 迁移之道
Azure 迁移之道
 
Facebook and its development
Facebook and its developmentFacebook and its development
Facebook and its development
 
What is silverlight?
What is silverlight?What is silverlight?
What is silverlight?
 

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

10 wp7 local database

  • 1. Windows Phone 7 Li Jingnan / Wang Tao 2011-7-15 1
  • 3. ethos http://www.ethostechnologies.com/ One of the 1st ISVs for cloud computing in Europe and China. Cloud computing development partner with Microsoft in Greater China Region. Invited to speak about Azure at several Microsoft events.
  • 4. about anytao| Ethos <ethos:Member id = “Wang Tao” msn = anytao@live.com weibo = http://weibo.com/anytao runat = “Senior System Architect” /> Jason | Ethos <ethos:Member id = “Li Jingnan” msn = zengnami@hotmail.com weibo= http://weibo.com/jn1981 runat = “SE” />
  • 6. 10 Local Database Wang Tao / 2011-07-15
  • 7. session outline LINQ to SQL LINQ to User Data overview architecture code-first development implementation details queries inserts, updates, deletes… database schema upgrades performance and best practices overview end-user consent supported account types implementation details querying contacts querying appointments performance and best practices
  • 8. LINQ to everything LINQ Objects XML SQL User Data OData 7 Mango
  • 9. complex schema numerous relationships and constraints example: shopping list 7 tables 100s of records 5 foreign keys
  • 10. Reference Data Huge amounts of static reference data Example: dictionary app 3 tables 1 table with 500k rows
  • 11. web service cache Cloud Service fetch reference data from cloud cache it locally combine with user-specific data Windows Phone Service Cache User Data
  • 12. user data filter contacts birthdays in the next month query all appointments find an available time for a meeting Filter
  • 14.
  • 15. unstructured data in Isolated Storage files
  • 16. structured data in database filesApp Root Folder Install Package Manager Creates root folder sandboxed to App DB Database File (r/o) App Data Folder Creates/Manages files and settings App WP7 Isolated Storage APIs DB Application Settings File Application Files Database file
  • 17. architecture Your App Custom Data Context App Objects var query = fromw indb.Wines wherew.Country== “USA" selectw.Name; System.Data.Linq Identity Management Change Tracking Update Processing Object Materialization .Call System.Linq.Queryable.Select( .Call System.Linq.Queryable.Where( .Constant(Table(Wines)), '(.Lambda #Lambda1)), '(.Lambda #Lambda2)) .Lambda #Lambda1(db.Wines $w) { $w.Country== “USA" } .Lambda #Lambda2(w.Country $w) { $w.Name} select Name from Wines where Country = “USA” Microsoft.Phone.Data.Internal Core ADO.NET (System.Data) SQL CE DB SQLCE ADO.NET Provider (System.Data.SqlServerCe)
  • 18.
  • 19.
  • 20. Translate object model into a database file
  • 21.
  • 22.
  • 23. queries: examples // Create the database form data context, using a connection string DataContextdb = newWineDataContext("isostore:/wineDB.sdf"); // Find all wines currently at home, ordered by date acquired varq = from w indb.Wines wherew.Varietal.Name == “Shiraz” && w.IsAtHome == true orderbyw.DateAcquired select w;
  • 24. Inserts/Updates/Deletes Your App Code It’s all about the DataContext Changes made against the DataContext first Changes persisted by calling SubmitChanges() SubmitChanges LINQ to SQL determines change set and submits to DB DataContext DB
  • 25. inserts/updates/deletes update insert WinenewWine= newWine { WineID= “1768", Name = “Windows Phone Syrah", Description = “Bold and spicy" }; db.Wines.InsertOnSubmit(newWine); db.SubmitChanges(); Winewine= (fromw indb.Wines wherew.WineID== “1768" select w).First(); wine.Description= “Hints of plum and melon"; db.SubmitChanges();
  • 26. inserts/updates/deletes delete varvineyardsToDelete= fromVineyards v in db.Vineyards wherev.Country== “Australia” select v; db.Vineyards.DeleteAllOnSubmit (vineyardsToDelete); db.SubmitChanges(); Foreign key constraint will cause exception here if Wines associated with the Vineyards are not deleted first
  • 27. inserts/updates/deletes varvineyardsToDelete= fromVineyards v indb.Vineyards wherev.Country== “Australia" select v; foreach (Vineyards v invineyardsToDelete) { db.Wines.DeleteAllOnSubmit(v.Wines); } db.Vineyards.DeleteAllOnSubmit(vineyardsToDelete); db.SubmitChanges();
  • 28. database schema upgrades DatabaseSchemaUpdater allows for simple upgrades on your existing DB It offers the ability to add Tables Columns Indices Associations/foreign keys All schema updates are transactional More complex schema upgrades require full DB migration
  • 29. Database Schema Upgrades Create a new DatabaseSchemaUpdater MyDerivedDataContext context = newMyDerivedDataContext("foo.sdf");DatabaseSchemaUpdaterdbUpdater = context.CreateDatabaseSchemaUpdater(); Add a new table tied to the Product class dbUpdater.AddTable<Winemaker>(); Add a Region column to the Customer table dbUpdater.AddColumn<Vineyard>(“YearEstablished"); Execute upgrade dbUpdater.Execute();
  • 30. performance and best practices keep change sets small Submit early and often to avoid data loss on app termination use background threads Non-trivial operations will impact app responsiveness if done on UI thread optimize read-only queries Set ObjectTrackingEnabled to minimize memory usage use secondary indices for properties which you query often
  • 31. performance and best practices populate large reference data tables in advance Create a simple project to prepopulate data in emulator Pull out database file using Isolated Storage explorer when to use a database… expect some impact to startup time and memory usage from incorporating a DB stick to IsolatedStorageSettings or basic files for small data sets
  • 33. new and updated APIs in “Mango” Chooser Tasks related to user data EmailAddressChooserTask PhoneNumberChooserTask AddressChooserTask Microsoft.Phone.UserData for direct access Contacts Appointments
  • 34. AddressChooserTask privateAddressChooserTaskaddressChooserTask; // Constructor publicMainPage() { this.addressChooserTask= newAddressChooserTask(); this.addressChooserTask.Completed += new EventHandler<AddressResult>( addressChooserTask_Completed); } privatevoidaddressChooserTask_Completed(objectsender, AddressResulte) { if(null == e.Error && TaskResult.OK == e.TaskResult) { ... = e.DisplayName; ... = e.Address; } }
  • 35. Microsoft.Phone.UserData Important points Contacts and Appointments APIs are read only Third party social network data cannot be shared
  • 37. contacts: hello, world! Contactscontacts = newContacts(); contacts.SearchCompleted+= newEventHandler<ContactsSearchEventArgs>((sender, e) => { ...= e.Results; }); // E.g. search for all contacts contacts.SearchAsync(string.Empty, FilterKind.None, null); state // E.g. search for all contacts with display name matching "ja" contacts.SearchAsync("ja", FilterKind.DisplayName, null); filter expression (not a regex) Filter kind: name, email , phone or pinned to start)
  • 38. appointments: hello, world! Appointmentsappointments = newAppointments(); appointments.SearchCompleted+= newEventHandler<AppointmentsSearchEventArgs>((sender, e) => { ... = e.Results; }); // E.g. get next appointment (up to 1 week away) appointments.SearchAsync(DateTime.Now, DateTime.Now+ TimeSpan.FromDays(7), 1, null); start date and time end date and time Maximum items to return state
  • 39. performance and best practices be responsible your privacy policy should cover how you use the user’s contact information keep out of the way users have widely varying contact list sizes your UI should handle delays gracefully don’t let data get stale data returned is a snapshot refresh state when reasonable
  • 40. demo 35 / linq to sql / datacontext / CRUD / user data 04 user manager
  • 41. practice 36 a todo list
  • 42. thank you 37 thank youwww.anytao.com
  • 43. 38