以 .net ria services 打通 silverlight 分散式開發之任督二脈

Post on 24-Jun-2015

1.667 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

以.NET RIA Services打通Silverlight分散式開發之任督二脈

奚江華

作家/微軟講師/技術顧問

2

Agenda

.NET RIA Services目標功能定位

RIA Services運作主要觀念

定義DomainServices的CRUD

Entity Framework的ORM資料來源

RIA Services支援的型別

Asynchronous Domain Operations

Silverlight DomainDataSource

ASP.NET使用DomainService

Validation to Entities

3

為什麼需要.NET RIA Services?Silverlight沒有傳統ADO.NET及SqlDataSource

協助快速建立、開發分散式的Silverlight應用系統

4

.NET傳統的資料存取技術

• ADO.NET• DataSource控制項

5

.NET RIA Services到底想幹嘛?

目標:針對建立N-tier應用程式的複雜度而來

Framework:提供撰寫程式所需的規範patterns

Tools:VS 2008有效整合Client及mid-tier為一體

Services:如帳號及群組驗證、使用者設定等服務

6

Client與Mid tier的Trust Boundary

7

RIA Services價值主張

支援end-to-end的資料使用

統合應用系統的Client與Server端程式開發

提供現成的Patterns與Services增加生產力

8

RIA Services的資料存取示意圖

9

RIA Services運作主要觀念

10

建立使用RIA Services的SL專案

11

建立使用RIA Services的專案

以Silverlight 3專案為例

12

專案的RIA link的開啓與關閉

Web專案可以調整RIA link的Enable與Disable

13

DomainService建立與消費

ASP.NET透過DomainDataSource存取DomainService服務

Defining Query Methods

14

定義DomainServices的CRUD

定義CRUD方法之原則

回傳型別single instance T

IEnumerable<T>

IQueryable<T>

使用零或多個參數

使用[Query] attribute

Domain的operations不支援方法的多載

15

DomainService之CRUD

定義CRUD方法之原則

16

Entity Framework資料存取架構圖

VS 2008 SP1 EDM工具

程式設計

17

Entity Data Model(EDM)

E-R Model & Entity Data Model

EDM設計目標

EDM主要成員

一體通用的Data Model資料模型

18

EDM主要定義檔成員Conceptual Model

定義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)

19

以LINQ to Entity查詢

以Employees資料表為例

20

RIA Services支援的型別Simple Type

Boolean、Byte 、 SByte 、 Int16 、 Char 、Double 、 Single String、Decimal、DateTime、TimeSpan、Guid、Uri、XElement

Complex TypeByte[]

System.Data.Linq.Binary

Array

IEnumerable<T>

Nullable<T>

Any types that implements IList

21

Asynchronous Domain Operations

LoadOperation(Query)

SubmitOperation(Submit)

InvokeOperation(Invoke)

Operation StateIsComplete

Completed event

UserState

Cancel () / CanCancel / IsCanceled

Error / HasError

22

Silverlight DomainDataSource

Loading Data

Parameterized Query Methods

Shaping DataSorting

Grouping

Filtering

Paging

Editing

23

以Silverlight為例

DomainDataSource的應用

24

ASP.NET使用DomainService

Entity Framework或LINQ to SQL

Domain Service Class

DomainDataSource

25

DomainService的使用

以ASP.NET GridView控制項為例

26

Validation to Entities

CustomValidationAttribute

DataTypeAttribute

RangeAttribute

RegularExpressionAttribute

RequiredAttribute

StringLengthAttribute

27

Validation的使用

以Entities為例

28

.NET RIA Services參考資源

.NET RIA Services

http://code.msdn.microsoft.com/RiaService

29

© 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.

top related