This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 有没有人分享一下好方法给 webservice 用 lazy loading?
-sowen(昂居居);
2011-12-16
{1232}
(#7147649@0)
-
估计没啥更好的方法,个人理解EF用在web application上比较合适,基本每次操作一条记录。Window/WPF程序做比较复杂的数据处理,还是要传统的复杂处理。
-tjhong(以后再说);
2011-12-16
(#7148117@0)
-
嗯,现在我们合同上只是做 service,对方的 front-end 是什么不都知道,只是纯粹用 message broker 软件来测试而已。如果做一个 deep loading,一个 request 要几乎十兆的数据,太慢了。客户的 legacy db 又不能碰,所以比较烦其实我也不是第一个遇到这样的麻烦,网上也有人问过
http://stackoverflow.com/questions/5762135/ef4-cause-circular-reference-in-web-service/5763627#5763627
但那里提到的方法基本也是我想的方法
估计以现在的技术是没有什么其他的了
-sowen(昂居居);
2011-12-16
{233}
(#7148129@0)
-
我想不出来你在save的时候要做什么特殊的处理。如果你是存customer信息的时候要改变contact的内容,那你怎么都避免不了;不改的话,要多处理什么?
-c1xwy(洪兴罩俺去战斗);
2011-12-16
(#7148215@0)
-
嗯,说错了,不是在 data service 上处理,是 service agent。因为那些 children 不再是 datamember 直接会被 serialized,那么我在 service agent 那里需要做(见内)。然后问题就是,我不能做 transaction 了save ()
{
serviceClient.SaveCustomer()
if (this.Contact.IsLoaded && this.Contact.IsChanged)
serviceClient.SaveContact( this.CustomerID, this.Contact )
}
这里的问题是,我没有办法把所有的 save 在 data service 那里放在一个 transaction 里面了
-sowen(昂居居);
2011-12-16
{274}
(#7148249@0)
-
WCF支持client's transaction的。==>
-tjhong(以后再说);
2011-12-16
(#7148900@0)
-
you are right, haha
-sowen(昂居居);
2011-12-21
(#7160339@0)
-
问得好,我差点就忘了 saving 要 transaction 的问题了。有什么好方法吗?
-sowen(昂居居);
2011-12-16
(#7148254@0)
-
我做的话,会分别写save, saveCustomer(), saveContact(), saveOrder(),"serviceClient.SaveContact( this.CustomerID, this.Contact ) ",Contact里面已经有customerID了,不用再显示的call了。
-c1xwy(洪兴罩俺去战斗);
2011-12-16
(#7148276@0)
-
你的意思是 multiple service operation contracts? 嗯,我觉得可能 transaction 并不是一个大问题,因为就算从上到下,中间有一个 child entity fails to save due to business logic failure,那至少可以 save others
-sowen(昂居居);
2011-12-16
(#7148332@0)
-
haha, 刚才下载了一本 entity framework in action,里面居然有一张是讲 lazy loading when serializing 的,有意思有意思
-sowen(昂居居);
2011-12-16
(#7148354@0)
-
i wrote some articles about handle large data using virtual list and paged data, it does not related with EF, but it might help.
-spruce(toastmaster);
2011-12-18
(#7152858@0)
-
不错,体现lazy loading的思想。
-tjhong(以后再说);
2011-12-19
(#7155519@0)
-
very nice work, very useful for paging, however, doesn't really apply the case of one entity with over 30 children entities
-sowen(昂居居);
2011-12-21
{1412}
(#7160403@0)
-
sound good. it will work
-spruce(toastmaster);
2011-12-23
(#7167153@0)
-
private int AdjustIndex(int index),里面又是linq又是foreach,可以简洁点吧。return
index + (from each in _removedItemIndexList).where(x=>x<index;).count();
-c1xwy(洪兴罩俺去战斗);
2011-12-21
(#7160487@0)
-
well, the AdjustIndex() implementation you suggested is much better than my previous implementation. thank you so much for the suggestion.
-spruce(toastmaster);
2011-12-23
(#7167189@0)
-
I re-exam the code and run unit test, and find that we can not use count linq count to do it. please see the details in content
-spruce(toastmaster);
2011-12-23
{1299}
(#7167299@0)
-
另外,"[Appendix]
Here is full source code. It is built by visual studio 2010."觉的应该是built in visual studio 2010
-c1xwy(洪兴罩俺去战斗);
2011-12-21
(#7160493@0)
-
thanks. good suggestion. i have updated it. and move the download to top of the article.
-spruce(toastmaster);
2011-12-23
(#7167107@0)
-
老大,中介给我发一个75$/h的Silverlight职位,愿意做就pm我
-binghongcha76(一只大猫);
2011-12-20
(#7159715@0)
-
thanks!!! but pass, after having a baby, i just want to stay at home everyday :)
-sowen(昂居居);
2011-12-21
(#7160342@0)