ado.net data services & entity framework
DESCRIPTION
Introduction to ADO.NET Data Services (Astoria Project) and Entity FrameworkTRANSCRIPT
1
ADO.NET Data Services&
Entity Framework
Diana NemeşuSeptember 2009
2
Agenda
Telemon Project Intro ADO.NET Data
Services:- Why?- How?
ADO.NET Entity Framework
Demo
3
Telemon Project
Purpose: to build a platform for e-health, namely a platform for Telemonitoring "anywhere and anytime”, in real time;
Parameters monitored: ECG, Resp, Temp, Acc, SPO2, Blood pressure
Technologies: - DB: SQLite, SQL Express; - ADO.NET / ADO.NET Data Services;
- WinForms, DevExpress
4
Telemon Overview
Sensor1
Sensor2
Device(SmartPho
ne)
Server Telemon
Telemon DataBase
Telemon Services
Doctor Applicati
on
5
Device Application
6
Doctors Application
8
Why?
Provides an API that allows data to be created and consumed over HTTP using RESTful service.
Supports all database operations using URI. Can expose an entity model via an URI. Is RESTful service to support CRUD operations
on database. Could be consumed by any type of client like
Windows, Silverlight, Web , AJAX and console.
9
How?
Data is sent over HTTP in both directions;
Defines a hosting interface IDataServiceHost that abstracts its implementation from a specific host (WCF, ASP.NET, IIS);
Server operations: - static layer that
implements URL translation - data source being surfaced
to the data service.
10
Concepts
REST: - focuses on key components that enable easy
integration and interaction with other systems;
- approaches the need for interoperability and communication between systems through separation of layers;- Yahoo, Facebook, Flickr, Amazon, Google, ebay, digg;
11
The ADO.NET Data Services framework provides patterns and libraries that enable the creation and consumption of data driven services for the web;
Expose Data Source to Data Service: - Entity Framework - LINQ to SQL - Surfacing custom data sources using CLR classes - Creating a custom IQueryable<T> provider to
surface a custom data source Offline-Enabled Data Services (Astoria Offline)
12
System Requirements
Microsoft .NET Framework 3.5 SP1
Visual Studio 2008 SP1
ADO.NET Data-access providers (Microsoft SQL Server 2005)
13
ADO.NET Entity Framework
Introduction ADO.NET Providers Entity Data Model (EDM) Mapping Database Schema vs
Conceptual Schema Using Object Model
http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx
14
Introduction to Entity Framework
Is a set of data access APIs for the Microsoft .NET Framework;
Version 1 was included with .NET Framework 3.5 SP1 and Visual Studio 2008 SP1; version 4.0 is available in Beta form as part of Visual Studio 2010;
Abstracts the relational(logical) schema of the data that is stored in a database and presents its conceptual schema to the application;
15
ADO.NET Providers: Connector/Net(MySQL), DB2.NET, dotConnect, Oracle Data Provider for .NET, DataDirect Connect for ADO.NET, Npgsql;
EDM: - specifies the conceptual model of the data via the Entity-Relationship data model;- the EDM schema is expressed in the Schema Definition Language (XML format);
Mapping: a 1:1 (one to one) mapping is generated between the database schema and the conceptual schema;
16
Database Schema Conceptual Schema
17
Using Object Model using(telemonEntities DB=new
telemonEntities()) { foreach (User user in DB.User) { Console.WriteLine("User{0} **
Username{1}", user.Id, user.Username); }
foreach (Alarme alarma in DB.Alarme) { Console.WriteLine( "Alarm: {0} ** Username: {1} **
Session: {2}", alarma.Id, alarma.User.Username, alarma.PacientSession.Name); }
ObjectQuery<SignalData> signals =
DB.SignalData;
IQueryable<SignalData> signalList = from s in signals select s;foreach (SignalData signal in signalList { Console.WriteLine("Signal{0} **
Session{1} ** Username{2}", signal.Id,
signal.PacientSession.Name,
signal.PacientSession.User.Username);
}
18
Demo