作者 主題: tech ed 2008 會後筆記 Data Service  (閱讀 4826 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
tech ed 2008 會後筆記 Data Service
« 於: 2008-10-02 15:07 »
Ado.net entity framework
n   Msdn blog

Ajax application
Silverlight

***Data rest interface
I.   Entity data model
A.   
II.   Uris
III.   http
IV.   data format


***ADO.net data services
1.   http -> http listening ->data services component -> Iqueryable -> data access layer ->entity framework or linq provider
**Devloping Environment
1.   visual studio 2008 sp1
2.   http 400 bad request
a.   check on the registry, add one machine code
i.   HKLM\SOFTWARE\Microsoft\ASP.NET
ii.   VerificationCompatibility
iii.   DWORD
iv.   Value 1
***Developing ADO.net data services
I.   Develop ADO.net data service steps
A.   Design entity data model, to descide the data schema from provision
B.   Set up ADO.net
C.   Test by client
D.   Using system.linq
E.   ADO.net entity Data modle
F.   Support SQL server, Get it from database
G.   It will show the connection string and write into web-config
H.   Pick up the table
I.   Project/ Add ado.net service
J.   Fill in the data entity model name in DataService<>
1、   SetEntitysetAccessrule(“*”, Entitysetrighs.all)
2、   Add one web site by vs .net in IIS
3、   Add network.service role on IIS to access all
4、   Turn off the anonymous acess off and widows acess on
5、   Reload (if see xml OK)

***pubish EDB
start one service
set the entity
set the acsess authority

***using Data service host
Data service is WCF service
Use by client
1、   ATOM:application/atom+xml
2、   JSON:application/json


***codepase
If db include the pictures, the result will show very long.
http get
webclient
xmldocument
credentialcache
xmlnamespacemanager (doc.nametable)
client.downloadstrin(“http://localhost/Northwind)
XMLnodelist datasourcenodes = doc.selectnodes(“//def.service”)
Use xpath to get the data
The parser should have the namespace
Atom: , use xml namespace add atom
1、   Addnamespace(“def”)
2、   Addnamespace(“atom”)
i.   To select all the entiry
3、   Webclient
4、   Client.headers.add(“accept”, “application/json”);
5、   Client.headers.add(“content-type”, “application/json”);
6、   Client.downloadstring
7、   Jobject jsondatasource


***interact with data service
CRUD
Post = create
Get = retrieve
Put = update
Delete = delete
remark
As soon as you can use http, you can also link to data service to access data.
If you don’t let the user to update, you can remark the “put”
Data service use uri to decide the query way
1、   Uri: http://[URL]/[ServiceName]/[entityName]/[NavigationOptions]?QueryOptions]
i.   Url: the data service locate address
ii.   Entity:
1.   /ds.svc/ProductProfiles
iii.   Set query
1.   /ds.svc/ProductProfiles?$filter=code eq ‘AKAFI’
iv.   Sequence
1.   /ds.svc/ProductProfiles?$filter= code eq ‘AKAFI’&$orderby=ProductID
v.   Paging
1.   /ds.svc/ProductProfiles?$filter= code eq ‘AKAFI’&$orderby=ProductID top skip

vi.   Group ()
vii.   Operator
1.   Add (+) sub(-), mul , div, mod
viii.   Logic
1.   And, or not, eq, ne, lt,gt,le,ge
ix.   Examples:
1.   Ds.svc/myentity?$filter((qty gt 10) le 50)
2.   Ds.svc/myentity?$filter=price ne 1500
x.   Function
1.   String function
2.   Math function
3.   Date function
4.   Type function
xi.   Expand
1.   Select all the deferred content
2.   Filter
3.   Order by
xii.   Refresh
1.   Use put
xiii.   Entity
1.   Post

Client.Uploadata (http://localhost/Northwinddataservices.svc/customers’,post”,

***Design Data service
1.   On the service , add in your own function
2.   Web get
3.   Client calling
a.   Ds.svc/[methodname]?[parameter-list]&query
b.   Public iquerytable<Category>
c.   Set accesssrule(“getCategories”,all)
4.   Build one method with parameter
5.   Ds.svc/[methodname]?[parameter]&query
6.   Query Interceptor
a.   Developer only use to check the
b.   Queryinterceptor(“entiryanem”)]
c.   Expression<Func<Categories, bool>>GetrestrictedCategory
d.   Expression<Func<entityclassname, bool>>GetrestrictedCategory



7.   Json or ATOM
a.   Suggest json
b.   Atom
1.   If more familiar to xml
8.   Entiry based data service access control
a.   Config.setentitysetaccessrule(“*”,entitysetrights.all)
b.   Config.setserviceoperationaccessrule(“GetCategorybyName”, serviceOperationrights.all);
9.   Error handling
a.   Args.Useverboseerrors = true
b.   Replace dataservice.handleexception
c.   Base.handleexception(args)
d.   Args.exception = new exception(“My Exception”);


***.net client libray
1.   Dataservicequery<T>.execute
2.   Siliverlight
a.   Httpwebrequest and heepwebresponse
b.   .net client library for silverilght 2.0
c.   Beginexecute()
d.   Endexecute()
e.   BeginSaveChanges
f.   EndSaveChanges
g.   Var query =  from
h.   Use ado.net service to exchange picture
i.   New
j.   
            

***username&password

??data service authentification


***Above resource is from 小朱 朱明中

ps: 強推他的書 asp.ent 問題解答集 很實用