Introduction to ADO'NET ObjectSpaces - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Introduction to ADO'NET ObjectSpaces

Description:

Dynamically builds SQL statements based on XML definitions of objects and database ... 'This' release only supports SQL Server 2000 or later as datasource ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 18
Provided by: alexth
Category:

less

Transcript and Presenter's Notes

Title: Introduction to ADO'NET ObjectSpaces


1
Introduction to ADO.NET ObjectSpaces Alex
ThissenTwice IT Training
2
Agenda
  • What is ADO.NET ObjectSpaces?
  • ObjectSpaces architecture
  • Mappings
  • Common classes
  • OPath query language
  • Questions and Answers

3
What is ObjectSpaces?
  • Object-Relational framework
  • Abstraction layer between
  • objects from application logic
  • data source
  • Extra layer on top of ADO.NET
  • Non-intrusive for object model
  • Dynamically builds SQL statements based on XML
    definitions of objects and database

4
Overview ObjectSpaces architecture
5
Three mapping files
  • Object Schema Document (.osd)
  • Defines business objects and members
  • Specifies relations between types of objects
  • Relational Schema Document (.rsd)
  • Defines tables and views
  • Mapping Schema Document (.msd)
  • Combines OSD and RSD
  • Maps between objects and tables
  • Also specifies how object-relations map to
    table-relationships

6
Types of relationships
  • Object relationships
  • One to One, One to Many, Many to Many
  • Inheritance
  • Objects to Table mappings
  • One object stored in one or more tables
  • Multiple objects stored in one table

7
DEMO
  • Business objects
  • Object Mapper Utility

8
(No Transcript)
9
ObjectSet
  • In-memory set of objects from source
  • Resembles DataSet
  • Keeps original values for optimistic concurrency
  • Can be bound to data controls
  • Streamable as XML (DiffGram style)
  • Automatic tracking of objects

10
ObjectReader
  • Provides a stream of objects from source
  • Enumerate using foreach loop or while loop
  • Is forward-only (not read-only)

11
ObjectSpace class
  • Handles communication to and from data source
  • Supports
  • State management
  • Transactions
  • Needs
  • One or more DB connections (ObjectSources)
  • Mapping file (MappingSchema)
  • Retrieve objects using
  • GetObject, GetObjectSet, GetObjectReader

12
ObjectQuery
  • Query that specifies search criteria for
    retrieving objects
  • GetObject, GetObjectReader, GetObjectSet
  • Needs three parameters
  • Type of object to retrieve
  • OPath query expression
  • Span (depth) of object hierarchy to return

ObjectQuery oq new ObjectQuery(typeof(Posting),
"ltOPath expressiongt", "ltSpangt") ObjectReader
or ObjectSpace.GetObjectReader(oq)
13
ObjectContext
  • Implicitly used by ObjectSpace and ObjectSet
  • Manages object identity
  • When object is requested that has been returned
    before, same object reference is used
  • Also works for links between objects
  • Weak references are used
  • More advanced scenarios work with ObjectContext
    explicitly

14
OPath Query language
  • OPath expressions are used to retrieve subsets of
    objects from source
  • Similar to XPath expressions
  • Filtering using predicates
  • Navigate object relations with dot (.) notation

// Some examples OrdersFreight gt
5.Details.Quantity gt 50 Customer.AddressState
Like 'A-C' Customer.Country 'USA' AND
Customer.Region 'WA' AddressState In ('WA',
'OR', 'ID') IIF(Gender 'M', 67, 72) - Age lt
Term Id Like ? AND OrdersFreight gt ?
15
DEMO
  • Retrieving objects
  • ObjectSet
  • Creating and storing objects

16
Advanced features
  • Delayed loading of nested objects
  • Collections are kept inside ObjectList instead of
    classes like ArrayList
  • "Read-only" objects
  • Not tracked by an ObjectContext
  • Optimal performance
  • Compiled queries

17
Things to keep in mind
  • "This" release only supports SQL Server 2000 or
    later as datasource
  • Although data source should implement
    IDbConnection
  • Cannot run (yet) from "in-process" Yukon stored
    procedures
  • Performance will be similar to working with
    DataAdapters and DataSets

18
Resources and links
  • PDC 2003 Samples
  • ObjectSpaces Mapper Utility
  • Object Persistence Sample
  • System.Data.ObjectSpaces documentation
  • Mail to osfdbk_at_microsoft.com

19
Questions and Answers
  • ?
Write a Comment
User Comments (0)
About PowerShow.com