Neo.NET Entity Objects Architecture and Implementation Copyright © 2002-2004 Erik Dörnenburg – Last updated: December 2004.

Slides:



Advertisements
Similar presentations
Michael Pizzo Software Architect Data Programmability Microsoft Corporation.
Advertisements

Keys, Referential Integrity and PHP One to Many on the Web.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 22 – Database: SQL, MySQL, DBI and ADO.NET Outline 22.1 Introduction 22.2 Relational Database Model.
Jeff Derstadt Senior Development Lead Microsoft Corporation Patterns & Architecture.
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
Client/Server Software Architectures Yonglei Tao.
Neo.NET Entity Objects Design Goals Copyright © Erik Dörnenburg – Last updated: May 2004.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
 2008 Pearson Education, Inc. All rights reserved Database: SQL, MySQL, ADO.NET 2.0 and Java DB.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
What is Architecture  Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project  In the.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Overview of Data Access MacDonald Ch. 15 MIS 324 Professor Sandvig.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
Databases and Data Access  Introduction to ADO.NET  ADO.NET objects  ADP.NET namespaces  Differences between ADO and ADO.NET.
.NET Data Access and Manipulation ADO.NET. Overview What is ADO.NET? Disconnected vs. connected data access models ADO.NET Architecture ADO.NET Core Objects.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Introduction to Database Development Using Borland Data Providers 2128 Martin Rudy.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
1 Databases November 15, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg. Published.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL ADO.Net Basics Ruwan Wijesinghe Trainer.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
ASP.NET Rina Zviel-Girshin Lecture 5
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Introduction to ADO.NET ADO.NET - Lesson 01  Training time: 10 minutes  Author:
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
FHIR Server Design Review Brian Postlethwaite HEALTHCONNEX October 2015.
ADO.Net TableAdapters and TableAdapterManager Code Camp 2008 Emmet Gray
Database Design Some of these slides are derived from IBM/Rational slides from courses on UML and object-oriented design and analysis. Copyright to the.
Mauricio Featherman, Ph.D. Washington St. University
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Copyright © 2007 InSTech Joint Laboratory All rights reserved. 1 Consideration on Persistence of WiseMan FuDan-Hitachi InSTech (Innovative Software Technology)
1 11/15/05CS360 Windows Programming ADO.NET Continued.
ARCH-7: Integrate this! SonicMQ® and the OpenEdge® Reference Architecture Christian Stiller Technical Architect.
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
Object storage and object interoperability
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Dr. Donald F. Ferguson.
Effective C# 50 Specific Way to Improve Your C# Item 22, 23.
DESIGNING A PERSISTENCE FRAMEWORK WITH PATTERNS. The Problem: Persistent Objects persistent object An object that can survive the process or thread that.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
The relational model1 The relational model Mathematical basis for relational databases.
Hibernate Thuy, Le Huu. Pentalog VN. Agenda Hibernate Annotations Improving performance – Lazy loading – Fetching Strategies – Dynamic insert, dynamic.
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
Neo.NET Entity Objects Patterns and Best Practices Copyright © Erik Dörnenburg – Last updated: December 2003.
1 Database Systems, 8 th Edition Star Schema Data modeling technique –Maps multidimensional decision support data into relational database Creates.
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
.NET Data Access and Manipulation
1 Copyright © 2008, Oracle. All rights reserved. Repository Basics.
1 SQL SERVER 2005 Express CE-105 SPRING 2007 Engr. Faisal ur Rehman.
Integrating Data Lesson 6.
Introduction to Entity framework
Database, SQL and ADO.NET
Introduction to Entity Framework
ADO.NET Framework.
VB.NET Using Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
Developing and testing enterprise Java applications
INHERITANCE.
Presentation transcript:

Neo.NET Entity Objects Architecture and Implementation Copyright © Erik Dörnenburg – Last updated: December 2004

Neo 1Architecture and Implementation The Big Picture System.Data integration Overview of the main classes More gory details

Neo 2Architecture: The Big Picture The Entity Object world and the ADO.NET world are brought together by Composition DataSet DataTable DataRow AuthorBase Author EntityObject ObjectContext * **

Neo 3Impl: ADO.NET integration Every entity object has a reference to its DataRow and to the context it belongs to. public class EntityObject { public DataRow Row { get { … }; } public ObjectContext Context { get { … }; } Data is stored in directly in row: public string FirstName { set { Row["au_fname"] = value; } get { return Row["au_fname"]; } Note how property names and column names can be mapped.

Neo 4Impl: ADO.NET integration To-one relation properties take the value from the related object and set it as foreign key value public class Title { public Publisher Publisher { set { Row["pub_id"] = value.Row["pub_id"]; } They use the context to find the object for the foreign key value in the related table get { return (Publisher)Context. GetObject("publishers", Row["pub_id"]); }

Neo 5Impl: ADO.NET integration To-many relations are managed by and exposed as typed collections public class Publisher { public readonly TitleRelation Titles; The relation collection objects have a reference to the object that owns the relation and a cache for the objects in the relation EntityObject PublisherBase Publisher ObjectColl'Base * EntityObject TitleBase Title ObjectRel'Base (*)(*) TitleRelation

Neo 6Impl: ADO.NET integration Relation objects work much like the relation properties. They manipulate the foreign key column of the affected object. public void Add(Title aTitle) { aTitle.Row["pub_id"] = Owner.Row["pub_id"]; } public void Remove(Title aTitle) { aTitle.Row["pub_id"] = null; } and use the context to find objects protected void Load() { innerList = Owner.Context.GetObjects( … );

Neo 7Architecture: The Big Picture The Entity Object world and the MS.NET world are brought together by Composition DataSet DataTable DataRow AuthorBase Author EntityObject ObjectContext * **

Neo 8Architecture: The Object Context Applications create as many contexts as required. context = new ObjectContext(); ObjectContext actually handles all of the CRUD operations, other methods are just a façade. public Class ObjectContext { IEntityObject CreateObject(Type objectType); IList GetAllObjects(Type objectType); IList GetObjects( … ); void DeleteObject(IEntityObject anObject);

Neo 9Architecture: The Object Context The context relies on its internal DataSet to track changes (creates, updates and deletes.) It provides methods to save or get the changes. public ICollection SaveChanges(); public void GetChanges(); Data can be added from other ADO.NET classes context.MergeDataSet(aDataSet); context.ImportRow(aDataRow); Factories create entity objects in a specific context; they use the context passed to the constructor. authorFactory = new AuthorFactory(myContext);

Neo 10Architecture: Data Stores A data store is responsible for retrieving and updating the backing store for the context. public interface IDataStore { DataTable Fetch(IFetchSpecification fs) ICollection Save(DataTable table) void BeginTransaction() … ObjectContext uses a data store to retrieve objects and save changes. A special data store could act as a façade for other data stores. I could select an appropriate store for a request and forward the request.

Neo 11Architecture: Disconnected clients Object contexts can work without a data store and take data directly from a DataSet. context = new ObjectContext(someDataSet); They allow indirect access to their internal DataSet so that changes can be made persistent. ds = context.GetChanges(); // do something to persist these changes, // maybe send dataset to a server... if(success) context.AcceptChanges();

Neo 12 Used to redistribute database generated keys. Neo generates temporary (negative) primary key values. Data stores provide a mapping from these temporary keys to the actual db values. table = new PkChangeTable("jobs"); table.AddPkChange(row["job_id"], actualKeyVal); Use in distributed environments: changes = clientContext.GetChanges(); serverContext.MergeDataSet(changes); pkctArray = serverContext.SaveChanges(); clientContext.UpdatePrimaryKeys(pkctArray); clientContext.AcceptChanges(); Architecture: PkChangeTable

Neo 13Architecture: Main classes ObjectContextEntityObject ObjectRel'Base ObjectFactoryObjectColl'Base SqlDataStore PkChangeTable IDataStore OracleDataStoreFirebirdDataStore

Neo 14Neo.Core and IEntityObject IEntityObject and a specific constructor are the minimal interface for an entity object: public interface IEntityObject { Neo.Core.ObjectContext Context { get; } System.Data.DataRow Row { get; } } public SomeClass(DataRow row, ObjectContect ctx) All core classes use IEntityObject only and do not impose the EntityObject/Base/User Class structure. Consequently, Neo.Core could be used to implement alternative entity object models.

Neo 15Internals: IFetchSpecification IFetchSpecification is used to select objects in object contexts and data stores. public interface IFetchSpecification { public IEntityMap EntityMap { get; } public Qualifier Qualifier { get; } } FetchSpecification is a straight-forward impl public class FetchSpecification : IFetchSpec… { public FetchSpecification(IEntityMap m, …) } Query Templates implement IFetchSpecification.

Neo 16Internals: IEntityMap Provides information about the mapping between database tables and entity objects. public interface IEntityMap { Type ObjectType { get; } string TableName { get ; } string[] Columns { get; } string GetColumnForProperty(string prop); Can generate ADO.NET schema information. void UpdateSchema(DataTable table, …) Neo provides an abstract implementation that is subclassed by generated classes, one per entity. This is likely to change; always use interface.

Neo 17Internals: IEntityMapFactory Entity map factories provide access to entity maps by table name or object type. public interface IEntityMapFactory { IEntityMap GetMap(string tableName); IEntityMap GetMap(Type objectType); ICollection GetAllMaps(); } DefaultEntityMapFactory is standard implementation that searches for IEntityMap implementers in all linked assemblies.

Neo 18Internals: IPkInitializer Contains a single method which must initialise a new database row. If scheme involves pk values provided by the application they are passed in. public interface IPkInitializer { void InitializeRow(DataRow row, object arg); } Neo has 5 implementations. public class UserPkInitializer public class NativePkInitializer public class GuidPkInitializer public class GuidStringPkInitializer public class NewGuidPkInitializer