ADO.NET Data Services&Entity FrameworkDiana NemeşuSeptember 20091
Agenda2Telemon Project
Intro ADO.NET Data Services:	- Why?	- How?ADO.NET Entity Framework
DemoTelemon Project3Purpose: 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 pressureTechnologies:	 - DB: SQLite, SQL Express; 	 - ADO.NET / ADO.NET Data Services;    - WinForms, DevExpress
Telemon Overview4Sensor1Sensor2Device(SmartPhone)Server TelemonDoctor ApplicationTelemonDataBaseTelemon Services
Device Application5
Doctors Application6
ADO.NET Data Services “Astoria”http://astoria.mslivelabs.com/ 7
Why?8Provides 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.
How?9Data 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.
Concepts10REST:     - 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;
11The 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 sourceOffline-Enabled Data Services (Astoria Offline)
System Requirements12Microsoft .NET Framework 3.5 SP1 Visual Studio 2008 SP1ADO.NET Data-access providers 	(Microsoft SQL Server 2005)
ADO.NET Entity Framework13IntroductionADO.NET ProvidersEntity Data Model (EDM)MappingDatabase Schema vs Conceptual SchemaUsing Object Modelhttp://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx
Introduction to Entity Framework14Is 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;
15ADO.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;
Conceptual SchemaDatabase Schema 16
Using Object Model 17using(telemonEntities DB=new telemonEntities()) {foreach (User user in DB.User)       {Console.WriteLine("User{0} ** Username{1}",user.Id,user.Username);        }foreach (Alarmealarma 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); }
Demo18

ADO.NET Data Services & Entity Framework

  • 1.
    ADO.NET Data Services&EntityFrameworkDiana NemeşuSeptember 20091
  • 2.
  • 3.
    Intro ADO.NET DataServices: - Why? - How?ADO.NET Entity Framework
  • 4.
    DemoTelemon Project3Purpose: tobuild a platform for e-health, namely a platform for Telemonitoring "anywhere and anytime”, in real time;Parameters monitored: ECG, Resp, Temp, Acc, SPO2, Blood pressureTechnologies: - DB: SQLite, SQL Express; - ADO.NET / ADO.NET Data Services; - WinForms, DevExpress
  • 5.
  • 6.
  • 7.
  • 8.
    ADO.NET Data Services“Astoria”http://astoria.mslivelabs.com/ 7
  • 9.
    Why?8Provides an APIthat 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.
  • 10.
    How?9Data is sentover 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.
  • 11.
    Concepts10REST: - 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;
  • 12.
    11The ADO.NET DataServices 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 sourceOffline-Enabled Data Services (Astoria Offline)
  • 13.
    System Requirements12Microsoft .NETFramework 3.5 SP1 Visual Studio 2008 SP1ADO.NET Data-access providers (Microsoft SQL Server 2005)
  • 14.
    ADO.NET Entity Framework13IntroductionADO.NETProvidersEntity Data Model (EDM)MappingDatabase Schema vs Conceptual SchemaUsing Object Modelhttp://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx
  • 15.
    Introduction to EntityFramework14Is 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;
  • 16.
    15ADO.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;
  • 17.
  • 18.
    Using Object Model17using(telemonEntities DB=new telemonEntities()) {foreach (User user in DB.User) {Console.WriteLine("User{0} ** Username{1}",user.Id,user.Username); }foreach (Alarmealarma 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); }
  • 19.
  • 20.
    19ADO.NET Data ServicesQuestionsDianaNemeşudin@rms.rodyana0106@yahoo.com