ado.net data services & entity framework

19
ADO.NET Data Services & Entity Framework Diana Nemeşu September 2009 1

Upload: dyana0106

Post on 25-Dec-2014

1.407 views

Category:

Documents


3 download

DESCRIPTION

Introduction to ADO.NET Data Services (Astoria Project) and Entity Framework

TRANSCRIPT

Page 1: ADO.NET Data Services & Entity Framework

1

ADO.NET Data Services&

Entity Framework

Diana NemeşuSeptember 2009

Page 2: ADO.NET Data Services & Entity Framework

2

Agenda

Telemon Project Intro ADO.NET Data

Services:- Why?- How?

ADO.NET Entity Framework

Demo

Page 3: ADO.NET Data Services & Entity Framework

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

Page 4: ADO.NET Data Services & Entity Framework

4

Telemon Overview

Sensor1

Sensor2

Device(SmartPho

ne)

Server Telemon

Telemon DataBase

Telemon Services

Doctor Applicati

on

Page 5: ADO.NET Data Services & Entity Framework

5

Device Application

Page 6: ADO.NET Data Services & Entity Framework

6

Doctors Application

Page 7: ADO.NET Data Services & Entity Framework

7

ADO.NET Data Services “Astoria”

http://astoria.mslivelabs.com/

Page 8: ADO.NET Data Services & Entity Framework

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.

Page 9: ADO.NET Data Services & Entity Framework

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.

Page 10: ADO.NET Data Services & Entity Framework

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;

Page 11: ADO.NET Data Services & Entity Framework

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)

Page 12: ADO.NET Data Services & Entity Framework

12

System Requirements

Microsoft .NET Framework 3.5 SP1

Visual Studio 2008 SP1

ADO.NET Data-access providers (Microsoft SQL Server 2005)

Page 13: ADO.NET Data Services & Entity Framework

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

Page 14: ADO.NET Data Services & Entity Framework

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;

Page 15: ADO.NET Data Services & Entity Framework

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;

Page 16: ADO.NET Data Services & Entity Framework

16

Database Schema Conceptual Schema

Page 17: ADO.NET Data Services & Entity Framework

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);

}

Page 18: ADO.NET Data Services & Entity Framework

18

Demo