DEVELOPING APPLICATIONS WITH LINQ 2 SQL Sidar Ok

Slides:



Advertisements
Similar presentations
Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Advertisements

January 30, 2014 Copyright Jim Farley Beyond JDBC: Java Object- Relational Mappings Jim Farley e-Commerce Program Manager GE Research and Development
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Jacinto Limjap, Jr. Senior Software Design Engineer, Cormant Technologies Inc. LINQ for NHibernate { Easy OR Mapping with C# and Visual Studio 2008 }
Object Relational Mapping – ORM Entity Framework
.NET Database Technologies: Open-Source Frameworks.
Jeff Derstadt Senior Development Lead Microsoft Corporation Patterns & Architecture.
.NET Framework V3.5+ & RESTful web services Mike Taulty Developer & Platform Group Microsoft Ltd
WCF RIA Services - Querying and Updating Data SILVERLIGHTSHOW.NET WEBINARS SERIES BRIAN NOYES, CHIEF ARCHITECT, IDESIGN INC 2 FEB 2011.
The Microsoft Technical Roadshow 2007 Advances for Data in VS “Orcas” Mike Taulty Developer & Platform Group Microsoft Ltd
© Copyright SELA Software & Education Labs Ltd Baruch Hirsch St. Bnei Brak Israel Microsoft Entity Framework v1.1 over Oracle Database Erez.
Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify.
Virtual techdays INDIA │ august 2010 Building ASP.NET applications using SQL Server Compact Chaitanya Solapurkar │ Partner Technical Consultant,
Introduction to ADO Entity Framework ir Denis VOITURON Source:
Entity Framework Code First End to End
Database Design for DNN Developers Sebastian Leupold.
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
RIA Services Master Class Presenter: Kevin Grossnicklaus November 30 th, 2010.
Michele Leroux Bustamante IDesign DTL201 Michele Leroux Bustamante Chief Architect IDesign: Microsoft Regional Director,
ADO.NET ENTITY FRAMEWORK Mike Taulty Developer & Platform Group Microsoft UK
Eric Nelson (or )
DAT336 Connected vs Disconnected Data Access in ADO.NET Pablo Castro Program Manager – ADO.NET Team Microsoft Corporation.
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK
M1G Introduction to Database Development 6. Building Applications.
DAT305 Boost Your Data-Driven Application Development Using SQL Server Centric.NET Code Generator Pascal Belaud Microsoft France.
.NET Database Technologies: Data Models and Patterns.
1 Hammad Khan. COURSE CONTENTS.NET Framework And C# SQL Server 2008 ADO.NET LINQ ASP.NET Dynamics Data ASP.NET MVC framework 2 Advance C# Concepts Windows.
Ronnie Saurenmann Principal Architect Microsoft Switzerland.
Alcatel-Lucent CDC Workshop, Coaching & Knowledge Transfer Architecture.
Reactive Database Access in Scala with Slick 3
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 14 Using Relational Databases to Provide Object Persistence (Overview) Modern Database.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Object Oriented Software Development 10. Persistent Storage.
Building Secure Web Applications With ASP.Net MVC.
Oct * Brad Tutterow. VS 2008.NET 3.5LINQ Entity Framework  The ADO.NET Entity Framework is part of Microsoft’s next generation of.NET technologies.
Copyright © 2004 J. Ambrose Little Introduction to Object-Relational Mapping for.NET.
1 ADO.NET Data Services Mike Taulty Developer & Platform Group Microsoft Ltd
The Business of IT ® Austin Code Camp ‘08 Prescriptive Data Access Development in.NET 3.5 Austin, TX May 17, 2008 Brian Orrell.
ADO.NET 3.0 – Entity Data Model Gert E.R. Drapers Chief Software Architect Visual Studio Team Edition for Database Professionals Microsoft Corporation.
Sean Chambers.  ORM stands for Object Relational Mapper  Maps your POCO (plain old clr objects) to your relational model using XML config  Relieves.
Architecting Real-World Enterprise Application. Agenda CPR - Background Challenges in the Architecture Architecture Details Q & A Summary.
2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK
Data Access Methodologies: When to choose what (ADO.NET, Entity Framework, WCF Data Services) Wriju Ghosh Lead Partner Consultant, Microsoft.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
2 ADO.NET Data Services for the Web Mike Flasko Program Manager, Microsoft “Project Astoria”
Top 10 Entity Framework Features Every Developer Should Know
Introducing the Microsoft® .NET Framework
Introduction to Entity framework
Beyond the BDC\BCS Model
Chris Menegay Sr. Consultant TECHSYS Business Solutions
Did your feature got in, out or planned?
Entity Framework By: Casey Griffin.
Entity Framework Core for Enterprise Applications
ADO.NET Entity Framework Marcus Tillett
ADO.NET Entity Framework
ADO.NEXT Advances in Data Access for 2008
DUCKS – Distributed User-mode Chirp-Knowledgeable Server
An Introduction to Entity Framework
ORMs and the DBA How to Make Both Happy.
Entity Framework Core.
ORMs and the DBA How to Make Both Happy.
Tech Ed North America /1/ :36 AM Required Slide
ORMs and the DBA How to Make Both Happy.
Entity Framework Core for Enterprise Applications
Developing and testing enterprise Java applications
Introducing Scenario Network Data Editing and Enterprise GIS
Visual Studio + SQL Server Is Better
.NET Framework V3.5+ & RESTful web services
Presentation transcript:

DEVELOPING APPLICATIONS WITH LINQ 2 SQL Sidar Ok

Agenda Common Glossary Problem Building in house ORM/DAL vs Use an existing one Linq to SQL Comes into play : Myths and Realities Linq to SQL beyond drag and drop : Concepts

Agenda (cont’d) Linq to SQL Entity Model Mapping Engine – Attribute Level or External ? SQL Metal to rescue – What it does, what it lacks Understanding DataContext Change Management & Change Communication Strategies

Agenda (Advanced) Debugging and Troubleshooting Transaction Handling Concurrency & Conflict Handling Scenarios Entity Validation Security Model Serialization Performance Advices & Best practices

Common Glossary ORM (Object Relational Mapper) Lazy (Deferred) Loading Eager Loading Unit of Work Pattern – Object (Dirty) Tracking Repository Pattern Law of Leaky Abstractions Plain Old CLR Objects (POCO) Persistence Ignorance TPH Model mapping DTO (Data Transfer Objects)

Problem Advanced programming in relational system = Pain of Hell redefined on earth Impedance Mismatch Re-Inventing the Flat Tire ? Over and Over ? – Basic CRUD ? Reacting to changes, maintainability

Solutions Putting Everything in DB Utilizing Custom Code Generation Using an Object Database Using a ready to go ORM – Linq to SQL – Entity Framework – Nhibernate (Open Source) – LLBLgen

Advises on Building Custom DAL/ORM

Linq to SQL into the pitch Microsoft’s Full Linq provider for MS SQL Built on top of ADO.NET – Previously owned by C#, now ADO.NET A designer and a RAD environment Plays well with System.Transactions Supports TPH model Supports custom queries & stored procedures

Myths & Realities L2S is for less advanced users L2S is slow L2S saves me building DAL L2S just supports SQL 2005 – 2000, 2005, 2008 & CE L2S doesn’t have an N-Tier story You have to have a db schema first You have to have attributes

Limitations and Drawbacks L2S doesn’t support : – Other DB vendors (Oracle, MySql etc) FYI There is a DBLinq project – Multi table mapping – Many to Many associations Designer experience isn’t the best Batched queries not supported OOTB Work disconnected, track yourself

Beyond Drag & Drop: L2S Concepts Object Tracking Deferred Loading – Load Options Optimistic Concurrency – Change Conflicts Change Sets

L2S Default Entity Model Entity Classes are partial – Drawback: Extension only in same assembly Entities implement “INotifyPropertyChanging”, “INotifyPropertyChanged” interfaces (1-1) -> EntityRef, – (1 - *) -> EntitySet Bunch of partial Methods (OnLoaded, OnCreated etc.)

Mapping Engine System.Data.Linq.Mapping namespace Mapping Engines Built in – Attribute Based (Internal Mapping) – Xml Based (External Mapping) L2S Designer doesn’t support XML Based – But SQL Metal tool does

Demo

Sql Metal – Can and Can’ts CAN Generate Entities – Option of Pluralizing Names – Option of giving them a base class CAN Generate DBML CAN Select from VB or C# CAN’T Partially Generate CAN’T Use on a Recursive SP There are alternatives – T4 Generation by Damien Guard (

Understanding DataContext A DataContext is a Unit of Work (UoW) Multiple DataContexts can share connections Work Modes – Connected & Disconnected.SubmitChanges – Transactional – Overload with Conflict Mode DataContext is the boss

DataContext is da boss Connected Mode – Life is easy – Throw an retrieve everything to/from DC – Object Tracking is a joy – Not very likely to happen  Disconnected Mode – Attach untracked objects for Update & Delete – Object Tracking doesn’t work

Change Tracking Strategies Track changes in UI – UI Box knows what it changed Pros – EntityBase, easy to implement – Hitting DB only once Cons – UI has to keep track – Keeping track & retrieving status from association trees can be daunting – Sending whole tree back is proven to be chatty

Sequence Diagram

Change Tracking Strategies (cont’d) Retrieving Entity Tree from DB – Hitting the DB to get original version and compare Pros – UI doesn’t need state management – DAL doesn’t care about any state, no implied contracts Cons – Hitting DB twice to retrieve – Needs a robust concurrency & error handling scenario – Still sending whole tree, chatty

Change Tracking Strategies(cont’d) Designing change DTOs – Sending only change sets as DTO s Pros – Decreases the communication cost in both ways – Encourages use of DTO s Cons – Still change tracking on the client boxes – Not trivial to implement – Mappings from/to DTO can be drudge

Change Tracking Strategies(cont’d) Designing change DTOs – Sending only change sets as DTO s Pros – Decreases the communication cost in both ways – Encourages use of DTO s Cons – Still change tracking on the client boxes – Not trivial to implement – Mappings from/to DTO can be drudge

Demo

Sum up Writing a custom ORM usually means reinventing the wheel Linq to SQL is a relatively powerful ORM It is an abstraction over SQL Server DataContext is at the center of all, implementing UoW pattern One can plug own mapping source Supports POCOs natively Only supports TPH Model

Advanced Topics Debugging and Troubleshooting Transaction Handling Concurrency & Conflict Handling Scenarios Entity Validation Security Model Serialization Performance Advices & Best practices

Thanks for listening ! Questions ? – –