ADO.NET Data Services & Entity Framework


Published on

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

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

ADO.NET Data Services & Entity Framework

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