开发者

linking the EF 4.0 context to the WCF call context

开发者 https://www.devze.com 2022-12-24 08:39 出处:网络
I would like to create an Entity Framework 4.0 context when a call is received and invoke to save changes when it finish, (som开发者_如何学JAVAething like JPA).

I would like to create an Entity Framework 4.0 context when a call is received and invoke to save changes when it finish, (som开发者_如何学JAVAething like JPA).

I think it is a good idea because I can use the state for all the call, It is short and encapsulate enogh to be threadsafe and long enough for caching calls and the context itself.

Any idea how is the best way for implement this?


Yes, definitely, that's the best way to go.

By default and by best practice recommendation, WCF service calls are "per-call", e.g. each requests gets a brand new, dedicated instance of the service class all to itself - no messy multithreaded/concurrency stuff to deal with - just a nice clean execution environment.

With EF 4, the "disconnected" scenario of sending back entities through WCF was one of the (many) areas that the EF team focused on. See some of these resources for more information:

  • Building N-Tier apps with EF4
  • More on disconnected Entity Framework
  • Attaching modified entities in EF4
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号