ADO.NET Entity Framework 技術指引與應用

Slides:



Advertisements
Similar presentations
網際網路資料庫連結 2004 Php Web Programming. 上完這段課程,你將學會  一般靜態網頁與互動式網頁的區別。  網際網路上大量資料的存取。  資料庫的角色與功能。  Web Server 的角色與功能。  網際網路資料庫的應用。  基本的程式寫作技巧及網頁的應用。
Advertisements

Software Engineering for Digital Home 單元 2 :軟體處理程序與需求分析 2-3 需求工程處理程序 Presenter: Away.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
第 10 章 Java 的執行緒 10-1 執行緒的基礎 10-2 Java 執行緒的使用方法 10-3 Java 執行緒的同步 10-4 管道串流的執行緒.
EBI European Bioinformatics Institute. EBI The European Bioinformatics Institute (EBI) part of EMBL is a centre for research and services in bioinformatics.
什麽是 WiMAX ? WiMAX 代表 Worldwide Interoperability for Microwave Access ,是屬於 IEEE 標準 的一種點到多點寬頻無線存取技術。 與 標準定義的 Wi-F 網路一樣, WiMAX 也 是一種無線上網技術,只是它的訊號範圍更廣、
核心能力意見調查 計畫主持人:劉義周教授 研究助理: 林珮婷 報告日期: 調查案的目標與性質 調查的主要目的在進行宣傳,讓全校師生可以瞭 解何謂「課程地圖」與「核心能力」。 通識中心將核心能力主要區分為「學術訓練」、 「就業準備」、「公民文化養成」、「個人特質 提升」等四大面向,本調查依據此四大面向進一.
在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息. 檔案下載  範例程式可在下列網址取得  DEMO 程式可在下列網址取得
 Prentice Hall Chapter 71 科技與工作流程設計.  Prentice Hall Chapter 72 學習目標 了解科技如何影響生產力 討論電腦輔設計 認識彈性製造系統 定義組織再造的三項要素 資訊科技如何支援決策.
1 Advanced Chemical Engineering Thermodynamics Appendix BK The Generalized van der Waals Partition Function.
Last modified 2004/02 An Introduction to SQL (Structured Query Language )
1.1 電腦的特性 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。
1. 假設以下的敘述為一未提供 “ 捷徑計算 ” 能力的程式段,試用程 式設計的技巧,使此敘述經此改 寫的動作後,具有與 “ 捷徑計算 ” 之 處理方法相同之處理模式。 if and then E1 else E2 endif.
各種線上電子資源的特異功能 STICnet 的 SDI 專題訂閱服務 2003/4/28 修改. 無論校內外皆可使用。連線至
第 2 章 資料庫系統的概念與架構.
第 18 章 名稱空間與例外處理 18-1 名稱空間 18-1 名稱空間 18-2 例外處理 18-2 例外處理.
系統分析與設計【第八版】 第六章 物件塑模.
產品資料管理 Product Data Management 學生:劉浩然 學號: G 指導老師:朱海成 博士.
JAVA 程式設計與資料結構 第十章 GUI Introdution III. File Chooser  File Chooser 是一個選擇檔案的圖形介面, 無論我們是要存檔還是要開啟檔案,使 用這個物件都會讓我們覺得容易且舒適。
© The McGraw-Hill Companies, Inc., 2008 第 6 章 製造流程的選擇與設計.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
Wireless Protocol Bluetooth
Advisor: 黃三益 教授 Student: 陳慧靜 D 鄭光廷 D
Chapter 13 塑模靜態觀點:物件圖 Static View : Object Diagram.
Introduction to Java Programming Lecture 17 Abstract Classes & Interfaces.
第 5 章 深入 Response 物件 製作. 網頁的轉向與強制輸出 - 讓網頁轉彎的 Redirect 敘述 運用 Response 物件的 Redirect 方法,將瀏覽器顯 示的網頁,導向至其他網頁,語法如下: Response.Redirect 網頁路徑與名稱 此網頁路徑與名稱  若是導向到同一台.
第 1 章 認識資料庫系統 著作權所有 © 旗標出版股份有限公司.
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
8-1 Chapter 8 技術與流程 組織的技術 製造業的核心技術 服務業的核心技術 非核心技術與組織管理 工作流程的相依性.
Chapter 20 塑模動態觀點:狀態圖 Statechart Diagram. 學習目標  說明狀態圖的目的  定義狀態圖的基本記號  展示狀態圖的建構  定義活動、內部事件及遞延事件的狀態 圖記號.
台灣客家知識治理之研究 -- 以 行政院客委會為例 發表人: 彭安麗 南華大學公共行政與政策研究所助理教授 發表人: 彭安麗 南華大學公共行政與政策研究所助理教授
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 參 資料蒐集的方法.
第三章 自動再裝載運用篇 使用時機:裝載計劃完成時,尚有剩餘空 間的情形,維持已固定計劃而繼續做裝載 最佳化。以支持次日裝載計劃而提前調整 作業模式。 裝載物品設定和裝載容器設定如前兩章介 紹,於此不再重複此動作,直接從裝載計 劃設定開始,直接從系統內定的物品和容 器選取所需.
1 第六章 Blog 網誌 網誌已是 Web2.0 的最新指標. 2 教學目標  了解 Blog 的意義  了解 Blog 的功用  了解 RSS  能註冊 Blog 並加以使用.
生產系統導論 生產系統簡介 績效衡量 現代工廠之特徵 管理機能.
教材名稱:網際網路安全之技術及其應用 (編號: 41 ) 計畫主持人:胡毓忠 副教授 聯絡電話: 教材網址: 執行單位: 政治大學資訊科學系.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
1 Web of Science 利用指引 逢甲大學圖書館 參考服務組 單元六 個人化服務.
Section 4.2 Probability Models 機率模式. 由實驗看機率 實驗前先列出所有可能的實驗結果。 – 擲銅板:正面或反面。 – 擲骰子: 1~6 點。 – 擲骰子兩顆: (1,1),(1,2),(1,3),… 等 36 種。 決定每一個可能的實驗結果發生機率。 – 實驗後所有的實驗結果整理得到。
Image Interpolation Use SSE 指導教授 : 楊士萱 學 生 : 楊宗峰 日 期 :
Structural Equation Modeling Chapter 6 CFA 根據每個因素有多重指標,以減少 測量誤差並可建立問卷的構念效度 驗證性因素分析.
MANAGEMENT INFORMATION SYSTEMS 管理資訊系統. 企業的五大資源 人力 (Personnel) 人力 (Personnel) 資料 (Material) 資料 (Material) 機器設備 (Machines) 機器設備 (Machines) 金錢 (Money) 金錢.
Chapter 10 m-way 搜尋樹與B-Tree
第12章 多重表單與模組的應用程式 12-1 VB.NET的方案與專案 12-2 模組化VB.NET應用程式 12-3 多重表單的應用程式
網路介紹及其運用 講師陳炯勳. 5-2 IP 協定 ( 一 ) IP 協定運作 (1) – 網路成員:主機 (Host) 與路由器 (Router) – 路由表 – 電報傳輸運作.
概念性產品企劃書 呂學儒 李政翰.
1 © 2011 台灣培生教育出版 (Pearson Education Taiwan). 2 學習目標 1. 當面對可預測的變異性時,同步管理並改善供應鏈 中的供給。 2. 當面對可預測的變異性時,同步管理並改善供應鏈 中的需求。 3. 當面對可預測的變異性時,使用總體規劃將利潤最 大化。
第十一章 分析法. 2  分析法 (analysis method) 是以分析的方式來解 決,亦即把問題細分成其組成部分,以便發現其 真實特性以及各變數間的因果關係.
INFORMATION RETRIEVAL AND EXTRACTION 作業: Program 1 第十四組 組員:林永峰、洪承雄、謝宗憲.
 Prentice Hal Chapter 151 新興的領導議題.  Prentice Hal Chapter 152 學習目標 比較交換型與轉換型領導 定義魅力領導者的特質 確認有願景領導者所展現出來的技能 解釋構思如何影響領導 描述追隨者如何依賴領導者.
著作權所有 © 旗標出版股份有限公司 第 3 章 資料庫物件的關係. 本章提要 Access 資料庫物件的關係 Access 資料庫物件的關係 簡介 Access 的七大物件 簡介 Access 的七大物件 Access 的群組 Access 的群組.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 壹 企業研究導論.
-Artificial Neural Network- Matlab操作介紹 -以類神經網路BPN Model為例
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 參 資料蒐集的方法.
家庭社會工作 陳阿梅.
Microsoft Excel.
實體關係模型 (ER Model).
第12章 團體溝通情境中的領導者.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
計 算 機 概 論 Chapter 10 作業系統. Ch010 作業系統 2 學習目標  描述作業系統的兩個主要任務  定義記憶體及程序管理  解釋邏輯位址與實體位址間的關係  基礎:第 5.2 節 范紐曼 電腦架構  ( 第 5 章講義第 頁 )
幼兒行為觀察與記錄 第八章 事件取樣法.
Mapping - 1 Mapping From ER Model to Relational DB.
第 1 章 PC 的基本構造. 本章提要 PC 系統簡介 80x86 系列 CPU 及其暫存器群 記憶體: Memory 80x86 的分節式記憶體管理 80x86 的 I/O 結構 學習組合語言的基本工具.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
遠端北風資料庫 公佈時間: 2006/4/26 繳交截止時間: 2006/5/10. 作業目的 實作遠端資料庫瀏覽程式.
RMI CORBA Matt. 2 RMI VS CORBA 3 4 J2EE 5 Sample Application.
網際網路行銷與電子商務的定義 What are “ internet marketing ” and “ e-Commerce ” ? 銷售 ( 物品或服務 ) + 訂價 + 推廣 + 分配 + 、、 等 = 行銷 「銷售」是「行銷」的一部份 商務 指 銷售商品或服務的活動 電子商務:經由電腦與網路來進行商品或服務的銷.
SQL Server 2012 on Server Core新架構探討並與AlwaysOn完美整合
Presentation transcript:

ADO.NET Entity Framework 技術指引與應用 奚江華 作家/微軟講師/技術顧問 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Agenda OOP vs. Relational database Entity Data Model(EDM) ADO.NET Entity Framework架構 Entity Framework程式設計

OOP vs. Relational Database 4/6/2017 11:35 AM OOP vs. Relational Database Discusses 窺探Entity Framework架構 OOP vs. Relational Database Objects != Relational Data © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Entity Framework資料存取架構圖 程式設計 VS 2008 SP1 EDM工具

OOP v.s. Relational Database Object Oriented Programming has been around for decades Relational databases have been around for even longer Bridging the gap between these two has been a mostly manual task Modulo 3rd party solutions The core problem remains

Objects != Relational Data The fundamental problem is that relational data and objects in a programming language aren’t the same! They have different semantics, languages, etc Both are needed – how many applications don’t use a relational database, or have some type of data model? Object / Relational Mapping

OOP to Data Engine Disconnect Relational Model 4/6/2017 11:35 AM OOP to Data Engine Disconnect Relational Model © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

OOP to Data Engine Disconnect Object Model 4/6/2017 11:35 AM OOP to Data Engine Disconnect Object Model Diagram from MSDN – Development Tools and Languages – Visual Studio 2005 – Technical Articles – Visual Studio – ADO.NET Tech Preview: Entity Data Model © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Entity Data Model(EDM) Discusses E-R Model & Entity Data Model EDM設計目標 EDM主要成員 一體通用的Data Model資料模型 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

什麼是Entity Data Model? A abstract conceptual model of data Based on Entity-Relationship Model by Dr. Peter Chen (1976) Entities and Relationships between those Entities Entity Types Association Types Navigation Properties The EDM is able to bring relational data and OOP together

EDM設計目標 EDM可以讓Domain Model與組織使思考與使用資料達成一致性。 EDM Models可應用於 ADO.NET Entity Framework ADO.NET Data Services Framework ADO.NET Dynamic Data Framework Input to Reporting Visualization applications Intranet portal applications workflow applications

Sample Entity Data Model for a Blogging Database Application-level Domain

Entity Framework And EDM How does it bridge the gap? A model that works for both Common type system Inheritance Complex types EDM is not focused on application design as a whole, but on the design of your data

Entities As Objects Like an object Known type Distinct identity Properties hold scalar values Properties hold references to other entities Unlike an object Entity identity (A.K.A. primary key) Associations to other entities Lives within a collection

Entities As Relational Data Like relational data Primary key No behavior defined Relationships (associations) to other entities Lives within an entity set Unlike relational data No physical storage knowledge (tables, indexes, etc) Supports inheritance Complex types

What Does This Mean? Every layer in an application has unique requirements of the data, but they all use data in terms of Entities The EDM is the Lingua Franca of the stack – it bridges the gap between OOP and relational data Your data model is no longer tightly bound to your database or your application

一體通用的Data Model資料模型 Where you create a single model… Can be stored in your database That represents your business, but can be specialized That is used in your Web sites, Rich Client Applications, Mid tier solutions, etc That can be exposed via Web services That you can base your reports on That can be used as the model for your data cubes

Discusses Entity Framework架構 Entity Framework介紹 Entity Data Model工具 EDM主要定義檔成員 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

ADO.NET Entity Framework介紹 目的 EF能夠讓開發人員以Domain-Specific物件及屬性來處理資料,例如顧客、顧客地址等等 不必擔心底層儲存的Database、Tables及Column 讓開發人員在進行資料處理時可以提升抽象層次 減少建立及維護以資料為中心AP所需的程式碼 實作 EF負責Conceptual Model / Storage Model Mapping 開發人員只需與Conceptual Model物件互動 EF 負責轉換Query與Database之查詢作業 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

ADO.NET Entity Framework Features Entities Properties – primitive types or complex types Navigation property – represents relationship between entities Methods – implemented with partial classes LINQ to Entities Translates object queries to data store query Alternate method based query syntax © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

ADO.NET Entity Framework Benefits Developers work with business objects No requirement of relational structure knowledge Relational structure changes don’t mean recode Navigation of relationships by properties Does not require writing SQL DML queries Interaction with data store managed by framework IntelliSense Performance Deferred loading of data when needed © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

The Entity Framework ADO.NET Entity Framework是第一個實作EDM的產品 EF是一個應用程式開發的framework EDM Modeling tools Mapping EDM model to/from DB and CLR Object Services

Entity Data Model工具 Entity Data Model Wizard Entity Data Model Designer Update Model Wizard

建立Entity Data Model

Application-Level Domain 4/6/2017 11:35 AM 以EDM Wizard建立EDM demo 這個示範要一一呈現傳統Web Services所不能達到的困境 Application-Level Domain © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

EDM主要定義檔成員 Conceptual Model Storage Model(Logical Model) Mappings 定義Entities及Relationships Conceptual schema definition language file (.csdl) Storage Model(Logical Model) 目的是為了關聯式資料庫,將Entities及Relationships正規化成具有foreign key constrains的Table資料表 Store schema definition language file (.ssdl) Mappings 定義Storage 及Conceptual Model二者間的對應 Mapping specification language file (.msl)

demo 檢視EDM定義檔 .csdl .ssdl .msl 4/6/2017 11:35 AM 這個示範要一一呈現傳統Web Services所不能達到的困境 .csdl .ssdl .msl © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Discusses Entity Framework程式設計 Entity Framework細部架構圖 Object Services服務 ObjectContext & ObjectQuery Object Query查詢的三種方法 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Entity Framework細部架構圖

Object Services物件服務 它是EF的一個元件System.Data.Entity.dll 在System.Data.Objects & System.Data.Objects.DataClass兩大命名空間實作 兩大命名空間中包含一群服務類別 對EDM中Entity Types作業之中介服務 Query、Insert、Update、Delete ms-help://MS.MSDNQTR.v90.en/wd_entityframework/html/43014cf9-c9cb-4538-bfbb-197820b60038.htm

System.Data.Objects類別 CompiledQuery CurrentValueRecord ObjectContext ObjectParameter ObjectParameterCollection ObjectQuery ObjectQuery<T> ObjectResult<T> ObjectStateEntry ObjectStateManager MergeOption列舉 RefreshMode列舉

System.Data.Objects.DataClass類別 ComplexObject EdmComplexPropertyAttribute EdmComplexTypeAttribute EdmEntityTypeAttribute EdmPropertyAttribute EdmRelationshipAttribute EdmRelationshipNavigationPropertyAttribute EdmScalarPropertyAttribute EdmSchemaAttribute EdmTypeAttribute EntityCollection<TEntity> EntityObject EntityReference EntityReference<TEntity> RelatedEnd RelationshipManager StructuralObject 介面 列舉

Object Services物件服務功能 Querying data as objects Shaping query results Composing queries using builder methods Adding, changing, and deleting objects Saving changes to the data source Binding objects to controls Attaching objects / Detaching objects Serializing objects ms-help://MS.MSDNQTR.v90.en/wd_entityframework/html/43014cf9-c9cb-4538-bfbb-197820b60038.htm

Object Services物件服務功能.續 Managing object identities and tracking changes Managing concurrency Managing connections Using custom objects with an Entity Data Model ms-help://MS.MSDNQTR.v90.en/wd_entityframework/html/43014cf9-c9cb-4538-bfbb-197820b60038.htm

ObjectContext類別 EDM中Entities Type的Instance 對於Entity資料提供Object型式互動的能力 Connection to database MetadataWorkspace物件 ObjectStateManager物件 1.MetadataWorkspace物件是一個可以與應用程式Context中的EDM Metadata互動的中央Runtime服務元件。 2.ObjectStateManager是負責管理保存在快取中的物件。

ObjectQuery類別 ObjectQuery泛型類別代表了回傳零或多個強型別Entity Objects的查詢。 一個Object Query永遠屬於一個既存的Object Context,意即在使用ObjectQuery之前,一定要先建立一個Object Context。 因為Object Context提供了建構與執行查詢所需的Connection連線及Metadata資訊。

Object Query之執行 預設為遞延查詢(Defered Execution) 立即執行(Immediate Execution) foreach (C#) or For Each fill a List collection Execute method LINQ query operator- First or Any

Programming The Entity Framework

三種Object Query查詢語法類型 LINQ to Entity(Language-Integrated Query ) Entity SQL Object Query Builder Methods 這裡的Query查詢是指EDM所回傳的Entities物件的查詢,而此部分是由ObjectContext類別所負責,再者 Query查詢編寫的語法有三種類型

以LINQ To Entities進行查詢 Queries against the generated classes All the benefits of LINQ Compile time type checking Intellisense Etc Query results are materialized objects Entity Types Anonymous Types Scalar values

LINQ to Entity運作流程 Step 1:建立ObjectContext Step 2:建立ObjectQuery & LINQ Query Step 3:LINQ Query  Command Tree(EDM) Step 4:EntityClient  Command Tree(DBMS) Step 5:將結果以物件型式回傳 1.ObjectQuery在使用前,必須先建立好ObjectContext,因為它提供Connection及Metadata給ObjectQuery 2. 4.EntityClient Data Provider將Command Tree(EDM)轉換成DBMS的Command Tree,執行Query查詢

demo 以LINQ to Entity查詢 以Products資料表為例 4/6/2017 11:35 AM 這個示範要一一呈現傳統Web Services所不能達到的困境 以Products資料表為例 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

以Entity SQL進行查詢 SQL variant for working with Entity Data Model Understands inheritance, associations, etc String based, but not dynamic SQL Results can be either objects, or EntityDataReader Allows for higher performance when you don’t need objects

EF的未來

4/6/2017 11:35 AM © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.