SlideShare ist ein Scribd-Unternehmen logo
1 von 18
05 | Managing transactions and
concurrency
Adam Tuliper | Technical Evangelist
Christopher Harrison | Content Developer
Module Overview
• Working in a web application
• Managing concurrency
Working in a web application
What's special about web applications?
Edit Request Accept Request
Load Data
Build FormView Form
Web applications are stateless
• EF uses entity tracking to detect changes
– Entities can only be tracked if they're attached to a data context
• When the page is returned to the user, the data context goes
away
• When the user returns updated object to the server, the server
sees that as a new object
– Not a modification to an existing object
Basic process for updates and deletes
• Attach the object to the context
• Set the state as Modified or Deleted
• SaveChanges
• Notes, updates the entire object, not individual properties
DEMO
Modifying and deleting entities
Managing concurrency
Things can change
• Who knows how long someone will have their page up
• Options
– Optimistic
• TimeStamp/RowVersion
• ConcurrencyCheck to customize property
– Pessimistic
• Set a flag on a row to prevent modification
• Requires more work
Optimistic concurrency with RowVersion/TimeStamp
• RowVersion and TimeStamp mean the same thing
• Basic steps
– Add a property of type byte[]
– Decorate the property with TimestampAttribute
[Timestamp()]
public byte[] RowVersion { get; set; }
What happens if something's changed
• EF automatically supports optimistic concurrency
• Adds WHERE statement to UPDATE and DELETE statements
• Throws OptimisticConcurrencyException if Timestamp has
changed
DEMO
Optimistic concurrency
Custom property
• If you want more control over how concurrency is handled, you
can choose which property or properties will be examined by EF
– Useful for legacy apps or databases that don't support timestamps
• Add ConcurrencyCheckAttribute to property
• EF will do the same WHERE check as before
DEMO
Custom property optimistic concurrency
Transactions
Saving multiple objects
• SaveChanges is transactional
• If you need a transaction to maintain across multiple calls, use
TransactionScope
DEMO
Custom transactions
©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the
U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft
must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Weitere ähnliche Inhalte

Was ist angesagt?

LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEXLOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
Enkitec
 
Team Development on Force.com with Github and Ant
Team Development on Force.com with Github and AntTeam Development on Force.com with Github and Ant
Team Development on Force.com with Github and Ant
Salesforce Developers
 

Was ist angesagt? (20)

Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Team Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & ReportingTeam Foundation Server - Tracking & Reporting
Team Foundation Server - Tracking & Reporting
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introduction
 
Take a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applicationsTake a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applications
 
Ruby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich CollinsRuby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich Collins
 
Six simple steps to unit testing happiness
Six simple steps to unit testing happinessSix simple steps to unit testing happiness
Six simple steps to unit testing happiness
 
Visual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) OverviewVisual Studio LightSwitch (Beta 1) Overview
Visual Studio LightSwitch (Beta 1) Overview
 
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEXLOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
LOBS, BLOBS, CLOBS: Dealing with Attachments in APEX
 
Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)Natural Language Classifier - Handbook (IBM)
Natural Language Classifier - Handbook (IBM)
 
Web application architecture
Web application architectureWeb application architecture
Web application architecture
 
PL/SQL Guilty Pleasures
PL/SQL Guilty PleasuresPL/SQL Guilty Pleasures
PL/SQL Guilty Pleasures
 
Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018Oracle SQL Developer - POUG 2018
Oracle SQL Developer - POUG 2018
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
 
Process builder vs Triggers
Process builder vs TriggersProcess builder vs Triggers
Process builder vs Triggers
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusion
 
Team Development on Force.com with Github and Ant
Team Development on Force.com with Github and AntTeam Development on Force.com with Github and Ant
Team Development on Force.com with Github and Ant
 
Oracle SQL Developer Reports
Oracle SQL Developer ReportsOracle SQL Developer Reports
Oracle SQL Developer Reports
 
Managing Your Batch and Scheduled Apex Processes with Relax
Managing Your Batch and Scheduled Apex Processes with RelaxManaging Your Batch and Scheduled Apex Processes with Relax
Managing Your Batch and Scheduled Apex Processes with Relax
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua RussellPower-Up Your Test Suite with OLE Automation by Joshua Russell
Power-Up Your Test Suite with OLE Automation by Joshua Russell
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 

Andere mochten auch

000 introduction
000 introduction000 introduction
000 introduction
sivorka
 

Andere mochten auch (20)

03 managing relationships
03   managing relationships03   managing relationships
03 managing relationships
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forward
 
01 introduction to entity framework
01   introduction to entity framework01   introduction to entity framework
01 introduction to entity framework
 
02 beginning code first
02   beginning code first02   beginning code first
02 beginning code first
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
001 hosting
001 hosting001 hosting
001 hosting
 
000 introduction
000 introduction000 introduction
000 introduction
 
C++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of ClassC++ 11 Style : A Touch of Class
C++ 11 Style : A Touch of Class
 
презентация привязка модели и валидация данных
презентация   привязка модели и валидация данныхпрезентация   привязка модели и валидация данных
презентация привязка модели и валидация данных
 
Mva stf module 6 - rus
Mva stf module 6 - rusMva stf module 6 - rus
Mva stf module 6 - rus
 
навигация и валидаторы презентация
навигация и валидаторы   презентациянавигация и валидаторы   презентация
навигация и валидаторы презентация
 
05 cерверные элементы управления презентация
05 cерверные элементы управления   презентация05 cерверные элементы управления   презентация
05 cерверные элементы управления презентация
 
Mva stf module 5 - rus
Mva stf module 5 - rusMva stf module 5 - rus
Mva stf module 5 - rus
 
Testing po
Testing poTesting po
Testing po
 
Mva stf module 4 - rus
Mva stf module 4 - rusMva stf module 4 - rus
Mva stf module 4 - rus
 
Mva stf module 1 - rus
Mva stf module 1 - rusMva stf module 1 - rus
Mva stf module 1 - rus
 
Mva stf module 3 - rus
Mva stf module 3 - rusMva stf module 3 - rus
Mva stf module 3 - rus
 
Mva stf module 2 - rus
Mva stf module 2 - rusMva stf module 2 - rus
Mva stf module 2 - rus
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 

Ähnlich wie 05 managing transactions

Microsoft master data services mds overview
Microsoft master data services mds overviewMicrosoft master data services mds overview
Microsoft master data services mds overview
Eugene Zozulya
 
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenanceOtm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
jucaab
 
2013 OTM EU SIG evolv applications Data Management
2013 OTM EU SIG evolv applications Data Management2013 OTM EU SIG evolv applications Data Management
2013 OTM EU SIG evolv applications Data Management
MavenWire
 
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.pptOracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
shubhtomar5
 
Advanced Application Lifecycle Managment
Advanced Application Lifecycle ManagmentAdvanced Application Lifecycle Managment
Advanced Application Lifecycle Managment
Salesforce Developers
 
Moving to the Maintenance Cloud
Moving to the Maintenance CloudMoving to the Maintenance Cloud
Moving to the Maintenance Cloud
Ian Monaghan
 

Ähnlich wie 05 managing transactions (20)

Microsoft master data services mds overview
Microsoft master data services mds overviewMicrosoft master data services mds overview
Microsoft master data services mds overview
 
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenanceOtm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
Otm 2013 c13_e-23b-hatcher-neil-otm-gtm-data-maintenance
 
2013 OTM EU SIG evolv applications Data Management
2013 OTM EU SIG evolv applications Data Management2013 OTM EU SIG evolv applications Data Management
2013 OTM EU SIG evolv applications Data Management
 
M.S. Dissertation in Salesforce on Force.com
M.S. Dissertation in Salesforce on Force.comM.S. Dissertation in Salesforce on Force.com
M.S. Dissertation in Salesforce on Force.com
 
Designing Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.comDesigning Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.com
 
Nicholas king oracle epm migration and upgrade
Nicholas king   oracle epm migration and upgradeNicholas king   oracle epm migration and upgrade
Nicholas king oracle epm migration and upgrade
 
Testing in the New World of Off-the-Shelf Software
Testing in the New World of Off-the-Shelf SoftwareTesting in the New World of Off-the-Shelf Software
Testing in the New World of Off-the-Shelf Software
 
Integration strategies best practices- Mulesoft meetup April 2018
Integration strategies   best practices- Mulesoft meetup April 2018Integration strategies   best practices- Mulesoft meetup April 2018
Integration strategies best practices- Mulesoft meetup April 2018
 
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
Webinar: Ten Ways to Enhance Your Salesforce.com Application in 2013
 
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comDesigning custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.com
 
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
15 Tips on Salesforce Data Migration - Naveen Gabrani & Jonathan Osgood
 
Salesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We DoSalesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We Do
 
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.pptOracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
Oracle-Fusion-Cloud-Vs-EBS-12.2.7-Upgrade-What-Suits-Your-Business-Best.pptx.ppt
 
Advanced Application Lifecycle Managment
Advanced Application Lifecycle ManagmentAdvanced Application Lifecycle Managment
Advanced Application Lifecycle Managment
 
E-Business Suite Customization Impact Assessment
E-Business Suite Customization Impact AssessmentE-Business Suite Customization Impact Assessment
E-Business Suite Customization Impact Assessment
 
State Management in Mule applications | MuleSoft Mysore Meetup #42
State Management in Mule applications |  MuleSoft Mysore Meetup #42State Management in Mule applications |  MuleSoft Mysore Meetup #42
State Management in Mule applications | MuleSoft Mysore Meetup #42
 
Applying systems thinking to AWS enterprise application migration
Applying systems thinking to AWS enterprise application migrationApplying systems thinking to AWS enterprise application migration
Applying systems thinking to AWS enterprise application migration
 
Salesforce Integration Pattern Overview
Salesforce Integration Pattern OverviewSalesforce Integration Pattern Overview
Salesforce Integration Pattern Overview
 
Summer '18 Developer Highlights
Summer '18 Developer HighlightsSummer '18 Developer Highlights
Summer '18 Developer Highlights
 
Moving to the Maintenance Cloud
Moving to the Maintenance CloudMoving to the Maintenance Cloud
Moving to the Maintenance Cloud
 

Kürzlich hochgeladen

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Kürzlich hochgeladen (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

05 managing transactions

  • 1. 05 | Managing transactions and concurrency Adam Tuliper | Technical Evangelist Christopher Harrison | Content Developer
  • 2. Module Overview • Working in a web application • Managing concurrency
  • 3. Working in a web application
  • 4. What's special about web applications? Edit Request Accept Request Load Data Build FormView Form
  • 5. Web applications are stateless • EF uses entity tracking to detect changes – Entities can only be tracked if they're attached to a data context • When the page is returned to the user, the data context goes away • When the user returns updated object to the server, the server sees that as a new object – Not a modification to an existing object
  • 6. Basic process for updates and deletes • Attach the object to the context • Set the state as Modified or Deleted • SaveChanges • Notes, updates the entire object, not individual properties
  • 9. Things can change • Who knows how long someone will have their page up • Options – Optimistic • TimeStamp/RowVersion • ConcurrencyCheck to customize property – Pessimistic • Set a flag on a row to prevent modification • Requires more work
  • 10. Optimistic concurrency with RowVersion/TimeStamp • RowVersion and TimeStamp mean the same thing • Basic steps – Add a property of type byte[] – Decorate the property with TimestampAttribute [Timestamp()] public byte[] RowVersion { get; set; }
  • 11. What happens if something's changed • EF automatically supports optimistic concurrency • Adds WHERE statement to UPDATE and DELETE statements • Throws OptimisticConcurrencyException if Timestamp has changed
  • 13. Custom property • If you want more control over how concurrency is handled, you can choose which property or properties will be examined by EF – Useful for legacy apps or databases that don't support timestamps • Add ConcurrencyCheckAttribute to property • EF will do the same WHERE check as before
  • 16. Saving multiple objects • SaveChanges is transactional • If you need a transaction to maintain across multiple calls, use TransactionScope
  • 18. ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Hinweis der Redaktion

  1. 1