开发者

EF4 STE include-path....exclude-path?

Context: Repository-pattern, WCF, WPF/SL

In my Repository of self-tracking Entities i need to explicitly load some related properties in order to correctly process the query. Those are not the includes requested by the client and i would lik开发者_JAVA技巧e to get rid of them in order to keep network traffic resonable. My solution so far is this:

  1. Receive Query
  2. Load includes necessary to answer request
  3. Execute Query
  4. Create temporary IEnumerable
  5. Iterate 4) and load all items again, this time with the include-path requested from the client-app only
  6. return entities via WCF

I would like to do this:

  1. Receive Query

  2. Load all includes (infrastructure plus client-requested)

  3. Execute Query

  4. Unload "Infrastructure" includes

  5. return entities via WCF

    What is the proper way to do this?

Thanks, Armin


How about lazy loading and proper DTO response objects ?

  1. WCF returns custom Order or GetOrderResponse (Contracts.Order)
  2. Load Order from EntityModel through repository (just the order)
  3. Use automapper for mapping EntityModel.Order => Contracts.Order

Result : only the corresponding properties inside Contracts.Order are loaded:

Ex. Contracts.Order Number OrderDetails (=> Only this property is loaded through lazy loading because it is mapped)

If you are building a SOA or webservice, don't let the client specify load graphs. If it's necessary for the client to specify load graphs consider deploying the Model using WCF Data Services, works great.

Perhaps you could build two systems .. one SOA and one (readonly) Data Service.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜