240 likes | 375 Views
Advanced Data Access Patterns. with ADO.NET 2.0. Julie Lerman The Data Farm. About Me. .NET Consultant and Mentor 20+ years developing Microsoft .NET MVP ASPInsider INETA Speaker Various publications & conferences Blogs: thedatafarm.com/blog, blog.ziffdavis.com/devlife
E N D
Advanced Data Access Patterns with ADO.NET 2.0 Julie Lerman The Data Farm
About Me • .NET Consultant and Mentor • 20+ years developing • Microsoft .NET MVP • ASPInsider • INETA Speaker • Various publications & conferences • Blogs: thedatafarm.com/blog, blog.ziffdavis.com/devlife • Founder and leader of Vermont .NET • INETA Speaker Committee, VTSDA Board
Agenda • ADO.NET 2.0 DataSet performance • Pushing huge data back to SQL Server • Caching huge amounts of data • Querying huge amounts of data in memory
New in ADO.NET 2.0 • New features used in this session • Batch Updating with DataAdapter • SqlBulkCopy Class • SqlDependency Class
ADO.NET 2.0 Performance • DataSet Scalability across the board • Can handle lots of rows • Indexing Engine completely re-written • Incremental indexing updates • much more • Low overhead for using Data Views • Serialization: Faster, more compact • Supports Binary & Schema-less serialization
Demonstration Indexing Engine Performance
Moving BIG Data • Getting data is easy and fast • Uploading is a different story • 1.1 Update Options • DataAdapter.Update – one row at a time • Controlled stored procedure update – one row at a time
Updating in 2.0 • DataAdapter Batch Update • Pushes groups of rows up to SQL Server • SQL Server still updates one at a time • Find sweet spot for UpdateBatchSize value • SqlDataAdapter & OracleDataAdapter • Bulk Copy • Streamed Insert using SQL Server Bulk Copy *slide slightly modified from original printed version
Demonstration Batch Update & Bulk Copy Class
Fast Updates w/BCP • Use BCP to stream Inserts & Updates and Deletes to temptables • Create & run a DML TSQL command to process inserts, updates and deletes from the temptables into the real tables • Wrap it all in a transaction • End to End streaming with DataReader DML: Database Manipulation Language
Demonstration Using BCP & DML to process huge amounts of data
DataSet Caching • DataSet improvements enable storing lots of data into cache • SqlDependency enables automated notification of changes to .NET • Combine SqlDependency and Caching for serious resource reduction
Demonstration SqlDependency & DataSet CachePart 1
Break up Big cache • SqlDependency is all or nothing • Create separate dependencies for logical sections of your cache
Demonstration SqlDependency & DataSet CachePart 2: Achieve granularity
Query BIG DataSet • Query a huge DataSet in cache • In-Memory Querying is coming! • LiNQ • VB9/C#3 • What about today? • ADO.NET 2.0 has everything you need to build a simple Query Processor • Great example of QP from ADO.NET Team Technical Lead Pablo Castro (“for demo only”)
Sample Query Processor • Takes advantage of new ADO.NET 2.0 tools • Ability to query huge datasets • Uses Caching • Super Fast indexing • DataTable.Select • DataView • Very simplistic compared to T-SQL • *NOT* for production use
Demonstration A look at a sample Query Processor written with ADO.NET 2.0
Summary • ADO.NET 2.0’s performance and functional improvements put new power in our hands • You can work with huge amounts of data efficiently • Functionality like BatchUpdate gives you easy access to some of this power • With a little more code, you can do wonders!
Resources • PDC05 Session DAT408, Pablo Castro, ADO.NET Team Technical Lead • ADO.NET Team Blog: blogs.msdn.com/dataaccess • MSDN Data Access Dev Center • msdn.microsoft.com/data • What’s New in ADO.NET 2.0, Julia Lerman, MSDN Magazine April 2005
ADO.NET 2.0 Bookshelf • ADO.NET and System.Xml v 2.0 – The Beta Version:Alex Homer, Dave Sussman & Mark Fussell, Addison-Wesley • PRO ADO.NET 2.0, Sahil Malik, APress • Professional ADO.NET 2: Programming with SQL Server 2005, Oracle, and MySQL, Wallace B. McClure, Gregory A. Beamer, IV John J. Croft, J. Ambrose Little, Bill Ryan, Phil Winstanley, David Yack, Jeremy Zongker, WROX Press • Programming Microsoft ADO.NET 2.0 Applications: Advanced Topics, Glenn Johnson, Microsoft Press • Microsoft ADO.NET 2.0 Step by Step, Rebecca Riordan, Microsoft Press
Contact Info Julie Lerman jlerman@thedatafarm.com www.thedatafarm.com Blogs www.thedatafarm.com/blog blogs.ziffdavis.com/devlife
Please fill out the survey forms!They are the key to amazing prizes that you can get at the end of each day Thank you!