Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify.

Similar presentations


Presentation on theme: "Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify."— Presentation transcript:

1 Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify

2 INTRODUCTION SQL Server Compact Edition and the Entity Framework Discover, Master, InfluenceSlide 2

3 The SQL Server Family Discover, Master, InfluenceSlide 3 The SQL Server 2008 Family of Products Enterprise Standard Workgroup Web Express Compact

4 Overview: SQL Server Compact Edition Relational Database Part of the SQL Server Family Runs on: – Windows Mobile Operating Systems – Windows XP – Windows Server 2003 – Windows Vista – Windows Server 2008 Discover, Master, InfluenceSlide 4

5 Why would I use Compact Edition? Benefits: Great for Disconnected Systems, Lightweight - low footprint, Support for T-SQL Critical Business Reports? Discover, Master, InfluenceSlide 5

6 Why would I use Compact Edition? Flat File based Memory and CPU conscious design Support for T-SQL, Encryption (but not Stored Procedures) In-Process Doesn’t Require a Service (unlike other SQL Server databases) ODBC/ADO Supported Also supported by the Sync Framework (SQL Server 2008) Discover, Master, InfluenceSlide 6

7 What’s new in Compact Edition 3.5? Synchronization (Sync Framework) Better integration with SQL Management Studio & Visual Studio Server Explorer Extended T-SQL support – CROSS APPLY – CAST – TOP – Identity (Insert) Local Transaction Scope (On Desktops) Unicode support LINQ to SQL Discover, Master, InfluenceSlide 7

8 Introducing the ADO.Net Entity Framework(EF) The goal of EF is to decrease the amount of code and maintenance required for data-oriented applications – Lets you create data access applications by programming against a conceptual model instead of writing directly against a database schema – Applications are freed from hard-coded dependencies on a particular data engine or storage schema. – ADO.NET Data Services enables data to be exposed as a REST-based data service that can be consumed by Web clients. Entity Framework is central to Microsoft’s data access strategy for the.Net Framework Shipped with.Net Framework 3.5 Service Pack 1 Underpinned by LINQ to Entities Discover, Master, InfluenceSlide 8

9 The Entity Data Model The Entity Data Model is a Entity-Relationship data model which supports advanced features such as: – Abstract classes – Property / Entity renaming – Inheritance – Complex Types – Stored procedure mapping for insert, update and delete methods. – Mapping a single entity to multiple tables – Hiding join tables in collections – Documentation which populate Xml comments Discover, Master, InfluenceSlide 9

10 .Edmx Files The Entity Data Model uses a.edmx file which consists of 3 sections – Conceptual Schema Definition Language(CSDL) Defines your application’s data objects. – Store Schema Definition Language (SSDL) – Defines the storage layer Defines the layout of your database – Mapping Specification Language (MSL) – Defines the mapping between the conceptual layer and the storage layer. Maps items from the conceptual layer to the storage layer Abstracts the EDM from you – Created by the Designer (or by hand, if you are game) – Managed by the Metadata Workspace at run time – Embedded in your assembly as a resource Entity Connection String specifies the data location – Use EntityConnectionStringBuilder to build a connection string at runtime Discover, Master, InfluenceSlide 10

11 Entity SQL Write queries independently of the data store with a more concise language – Provides a common query language across providers by extending the existing SQL language with constructs to work with strong notions of type, inheritance, and relationships from the Entity Data Model SQL – SELECT sp.FirstName, sp.LastName, sp.HireDate FROM SalesPerson sp INNER JOIN Employee e ON sp.SalesPersonID = e.EmployeeID INNER JOIN Contact c ON e.EmployeeID = c.ContactID WHERE e.SalariedFlag = 1 AND e.HireDate >= '2006-01-01' Entity SQL – SELECT sp.FirstName, sp.LastName, sp.HireDate FROM AdventureWorks.AdventureWorksDB.SalesPeople AS sp WHERE e.HireDate >= '2006-01-01‘ Only used for select statements Discover, Master, InfluenceSlide 11

12 Entity Framework Objects Metadata Workspace – Runtime component which maintains the CSDL, SSDL, MSL and CLR objects. Object State Manager – Maintains object state and identity management for entity type instances and relationship instances – Tracks query results, and provides logic to merge multiple overlapping query results. – It also performs in-memory change tracking when a user inserts, deletes, or modifies objects, and provides the change set for updates. This change set is used by the change processor to persist modifications Object Context – Primary class for interacting with data from a Entity Data Model – Encapsulates a connection to the database, the metadata workspace and the object state manager – Handle this like you would handle a Sql connection – open/close. For windows forms, use one ObjectContext per application instance. For web forms, use one ObjectContext per request – and use the EntityDataSource! Discover, Master, InfluenceSlide 12

13 PRACTICAL IMPLEMENTATION SQL Server Compact Edition and the Entity Framework Discover, Master, InfluenceSlide 13 Image: http://www.techpin.com

14 How Compact Edition Works with the Entity Framework Scope of the demonstration: Compact Edition integration with Server Explorer and SQL Server Management Studio Create a SQL Server Compact Edition Database Query a Compact Edition database Discover, Master, InfluenceSlide 14

15 How Compact Edition Works with the Entity Framework [Demo] Discover, Master, InfluenceSlide 15

16 Further Reading See the full presentation next month at SQL Code Camp in Wagga Wagga October 11 th and 12 th 2008 References Discover, Master, InfluenceSlide 16

17 Getting Started with Entity Framework Reading – MSDN Library Page http://msdn.microsoft.com/en-us/library/bb399572.aspx http://msdn.microsoft.com/en-us/library/bb399572.aspx – ADO.NET Team Blog http://blogs.msdn.com/adonet http://blogs.msdn.com/adonet – MSDN Forum http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&Site ID=1 http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&Site ID=1 Resources – Microsoft.NET Framework 3.5 Service Pack 1 http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F- 5D1A-413D-8319-81DA479AB0D7 http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F- 5D1A-413D-8319-81DA479AB0D7 – Microsoft Visual Studio 2008 Service Pack 1 http://www.microsoft.com/downloads/details.aspx?familyid=FBEE1648- 7106-44A7-9649-6D9F6D58056E http://www.microsoft.com/downloads/details.aspx?familyid=FBEE1648- 7106-44A7-9649-6D9F6D58056E – eSqlBlast http://code.msdn.microsoft.com/esql. http://code.msdn.microsoft.com/esql Discover, Master, InfluenceSlide 17

18 Thank you Rob Sanders Readify http://www.readify.net http://www.twitter.com [Username @AusRob] http://www.twitter.com http://rob.sanders.namehttp://rob.sanders.name [Personal Site] http://internationalized.spaces.live.com [Blog] http://internationalized.spaces.live.com Discover, Master, InfluenceSlide 18


Download ppt "Discover, Master, InfluenceSlide 1 SQL Server Compact Edition and the Entity Framework Rob Sanders Readify."

Similar presentations


Ads by Google