.NET Database Technologies: Open-Source Frameworks.

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

An Object/Relational Mapping tool Free and open source Simplifies storage of object data in a relational database Removes the need to write and maintain.
Michael Pizzo Software Architect Data Programmability Microsoft Corporation.
NHibernate Object/Relational Persistence for.NET.
Ruby on Rails Tutorial Peter Mosca April, Ruby on Rails Tutorial Ruby History Invented 12 years ago in Japan by Yukihiro Matsumoto Spent first 5.
Hibernate 1. Introduction ORM goal: Take advantage of the things SQL databases do well, without leaving the Java language of objects and classes. ORM.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
Dr. Kalpakis CMSC 461, Database Management Systems Introduction.
Session-01. Hibernate Framework ? Why we use Hibernate ?
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 1: Introduction.
Entity Framework Code First End to End
UPortal Developers MIT August 2004 Persistence Strategy for uPortal 3 Mike DeSimone the r-smart group
.NET Database Technologies: Entity Framework additional notes – part 2.
Database Design for DNN Developers Sebastian Leupold.
Databases and LINQ Visual Basic 2010 How to Program 1.
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
Entity Framework, a quickstart Florin−Tudor Cristea, Microsoft Student Partner.
Data Access Patterns Some of the problems with data access from OO programs: 1.Data source and OO program use different data modelling concepts 2.Decoupling.
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
Entity Framework Overview. Entity Framework A set of technologies in ADO.NET that support the development of data-oriented software applications A component.
.NET Database Technologies: Data Models and Patterns.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Andrew S. Budarevsky Adaptive Application Data Management Overview.
Object-to-Relational Mapping: The Crossing Chasms Pattern and Implementation Considerations Use of Meta Data in the Java Persistence Layer Presented by.
© 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.
Intoduction to NHibernate. Agenda Overview of NHibernate Models and Mappings Configuration Sessions and Transactions Queries.
Applying Domain-Driven Design Jimmy Nilsson Webcast with UML China
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
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.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Intoduction to NHibernate. Agenda Overview of NHibernate Models and Mappings Configuration Sessions and Transactions Queries.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Persistence – Iteration 4 Vancouver Bootcamp Aaron Zeckoski
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Introduction – ORM, Helloworld Application
Fundamentals of MyBATIS
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
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.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
Reactor An ORM framework for ColdFusion Presentation By: Doug Hughes
Fall CIS 764 Database Systems Engineering L11: Object Relational Mapping … (a) ORM, Object persistence (b) Pets sequence.
Top 10 Entity Framework Features Every Developer Should Know
New Technology: Why, What ,How
Introduction to Entity framework
Don't Know Jack About Object-Relational Mapping?
Introduction to Entity Framework
A very brief introduction
Entity Framework By: Casey Griffin.
ADO.NET Entity Framework Marcus Tillett
ADO.NET Entity Framework
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
ADO.NEXT Advances in Data Access for 2008
An Introduction to Entity Framework
Entity Framework Core.
Data Model.
Developing and testing enterprise Java applications
Presentation transcript:

.NET Database Technologies: Open-Source Frameworks

Looking beyond Microsoft Many third-party ORM tools and frameworks are available for.NET and for other languages/platforms High level of maturity in the Java world in particular Open-source projects and commercial products We will look at two (closely-related) open-source frameworks which implement different patterns  Castle ActiveRecord  NHibernate

Active Record An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data Implemented by Castle ActiveRecord Part of Castle Project, which also includes Windsor, Dynamic Proxy, etc. Built on top of NHibernate

ActiveRecordBase Active record pattern  instance properties representing a record in the database  instance methods acting on that specific record  static methods acting on all records ActiveRecord implements this through ActiveRecordBase class All persistent classes inherit from it ActiveRecordBase implements a basic set of storage and retrieval operations, e.g. Create, FindAll, Save, Update Persistent classes can implement additional operations

ActiveRecord mapping Active record pattern assumes a fairly direct correspondence between objects and database “an object that wraps a row in a database table” Castle ActiveRecord is a bit more flexible than that basic description of pattern implies Makes use of capabilities of Nhibernate Offers a subset of NHibernate mapping functionality, including inheritance mapping Mapping is done using class, fields and property level attributes ActiveRecord is able to infer table and column names if you omit them  Convention over configuration

ActiveRecord queries Persistent classes can retrieve data and populate objects in the following ways:  Calling methods of base class  Calling methods of base class and using NHibernate criteria  Using SimpleQuery class to execute HQL queries (Hibernate Query Language)  Native SQL queries (through NHibernate)  LINQ(?)

Another pattern – Query Object An object that represents a database query. A Query Object is a structure of objects, including criteria, that can form itself into a SQL query You can create this query by referring to classes and fields rather than tables and columns In this way those who write the queries can do so independently of the database schema and changes to the schema can be localized in a single place

ActiveRecord and PI Not a chance! ActiveRecord is intended to be simple to use, without the need to learn NHibernate mapping schema Favours convention over configuration (this is not specifically a property of the Active Record pattern) Suitable for Rapid Application Development rather than Domain Driven Development

Not just.NET - Ruby on Rails Probably the best known Active Record implementation Works with the Ruby language Persistent classes inherit from ActiveRecord::Base class Rails also implements MVC and favours convention over configuration throughout Other implementations exist for PHP, Java, etc.

Data Mapper/Metadata Mapping - NHibernate The Data Mapper is a layer of software that separates the in-memory objects from the database A Metadata Mapping allows developers to define the mappings in a simple tabular form, which can then be processed by generic code to carry out the details of reading, inserting, and updating the data NHibernate is an ORM which implements these patterns Relatively mature technology, ported from Hibernate which is long established for Java

NHibernate Unit of Work Session is roughly equivalent to EF’s ObjectContext Implements Unit of Work and Identity Map patterns Session instance is created by a SessionFactory object which is built by reading configuration file Session opens a Transaction in which to do the work Common practice to wrap Session in a custom Unit of Work at a higher level of abstraction

NHibernate mapping Mappings are defined in XML files or by annotations Very powerful and flexible mapping capabilities Detailed control of loading strategies, etc. Can map select, update, etc to stored queries Configuration (database connection, etc) also defined in XML files

NHibernate queries NHibernate can retrieve data and populate objects in the following ways (among others):  HQL queries  Criteria queries  Native SQL queries  LINQ  Named queries (HQL or SQL) defined in mapping

NHibernate and PI NHibernate persistent classes are POCOs Good adherence to PI principle Favoured by adherents of DDD

Fluent NHibernate Uses Fluent API to define NHibernate configurations and mappings in code Type-safe, no XML Similar to EF Code-First mappings (actually, it’s the other way round) Favours convention over configuration

Fluent APIs Term first coined by Evans and Fowler A fluent interface is normally implemented by using method chaining to relay the instruction context of a subsequent call The API is primarily designed to be readable and to flow Can be detrimental to debugging, as a fluent chain constitutes a single statement in which debuggers may not allow setting up intermediate breakpoints Becoming common for applications such as defining mappings, configurations and query objects (e.g. LINQ extension methods syntax)

ORMs and performance Using any ORM can be expected to have an impact on performance compared to ADO.NET  Overhead of extra layer on top of ADO.NET  Select N+1 problem  Sub-optimal SQL may be generated Hard to find reliable data to base decisions on  Some academic research (van Zyl, Cvetkovic)  Benchmarks ORMeter ( PolePosition (  Opinions and experience Weigh benefits against performance hit

Optimising ORM performance SQL Profiling Careful consideration of fetching/loading strategy within the application Careful design of mapping where possible Using stored procedures where appropriate Compiled queries and query-plan caching (LINQ) Pre-Build Store Views (EF) Tracking vs. No Tracking (EF) 2 nd level caching (NHibernate) etc...