<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4422419057570353749</id><updated>2015-08-08T19:58:54.757-07:00</updated><category term="WPF"/><category term="BizTalk"/><category term="DataGrid"/><category term="Silverlight"/><category term="linked list"/><category term="Email"/><category term="General"/><category term="IOS5"/><category term="IOS5 RESTful service authentication"/><category term="Map"/><category term="SQL Server 2005"/><title type='text'>My technical foot print</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-8788826815563116320</id><published>2013-09-24T05:43:00.002-07:00</published><updated>2013-09-24T05:43:31.583-07:00</updated><title type='text'>Silverlight RIA service, DomainContextBatchLoader</title><content type='html'>I am working on Silverlight these days. And we are using Silverlight RIA service and Entity framework to access database.&lt;br /&gt;&lt;br /&gt;If you had ever worked with RIA , you will come across a situation that you might want to load many entities from the server using different queries, before you can present an appropriate UI to your customer.&lt;br /&gt;&lt;br /&gt;for example, customer, you might want to load customer detail infomation, customer history, customer order etc etc.&lt;br /&gt;&lt;br /&gt;I did some search , and didn&#39;t find an appropriate batch loader, so create one by myself, in case someone else also need to implement similar features, can take it as a reference.&lt;br /&gt;&lt;br /&gt;&lt;pre style=&quot;background: #1e1e1e; color: gainsboro; font-family: Consolas; font-size: 13;&quot;&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;System&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Collections&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Generic&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Linq&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;System&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;ServiceModel&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;DomainServices&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Client&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;SilverlightApplication4&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContextBatchLoader&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;abstract&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadStep&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;bool&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;IsComplete&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;get&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;set&lt;/span&gt;;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;abstract&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;Execute&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Action&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;OnSuccess&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Action&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;OnFail&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BatchLoadStep&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadStep&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;where&lt;/span&gt;&amp;nbsp;T&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Entity&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContext&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_context&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;EntityQuery&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;EntityQuery&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;get&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;set&lt;/span&gt;;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;LoadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_loadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;LoadBehavior&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;MergeIntoCurrent&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#region&lt;/span&gt;&amp;nbsp;Construction&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;BatchLoadStep&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContext&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;context&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;EntityQuery&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;query&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;LoadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;loadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;LoadBehavior&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;MergeIntoCurrent&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_context&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;context&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;EntityQuery&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;query&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_loadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;loadBehavior&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#endregion&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#region&lt;/span&gt;&amp;nbsp;Overrides&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;override&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;Execute&lt;/span&gt;()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_context&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Load&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;EntityQuery&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_loadBehavior&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;IsComplete&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;LoadOperation&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;IsComplete&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;HasError&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnSuccess&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnSuccess&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnFail&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnFail&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#endregion&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;LoadOperation&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;get&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;set&lt;/span&gt;;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#region&lt;/span&gt;&amp;nbsp;Construction&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;DomainContextBatchLoader&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Action&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContextBatchLoader&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;completeAction&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;_completeAction&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;completeAction&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#endregion&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#region&lt;/span&gt;&amp;nbsp;Private&amp;nbsp;Properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Action&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContextBatchLoader&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_completeAction&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadStep&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadStep&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstFaildOperation&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;List&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;event&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;EventHandler&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;OnComplete&lt;/span&gt;;&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#endregion&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#region&lt;/span&gt;&amp;nbsp;Methods&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;(&lt;span style=&quot;color: #4ec9b0;&quot;&gt;DomainContext&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;context&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;EntityQuery&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;query&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;LoadBehavior&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;loadBehavior&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;where&lt;/span&gt;&amp;nbsp;T&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Entity&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;var&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BatchLoadStep&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;context&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;query&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;loadBehavior&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnSuccess&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;CheckComplete&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnFail&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;_lstFaildOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;lp&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;CheckComplete&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;};&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Add&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;CheckComplete&lt;/span&gt;()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Any&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;o&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;IsComplete&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;==&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;false&lt;/span&gt;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;_completeAction&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;_completeAction&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnComplete&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OnComplete&lt;/span&gt;(&lt;span style=&quot;color: #569cd6;&quot;&gt;this&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;EventArgs&lt;/span&gt;());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;void&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;Start&lt;/span&gt;()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Count&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b5cea8;&quot;&gt;0&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;ForEach&lt;/span&gt;(&lt;span style=&quot;color: white;&quot;&gt;o&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;o&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Execute&lt;/span&gt;());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;CheckComplete&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;GetEntities&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;T&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;where&lt;/span&gt;&amp;nbsp;T&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;Entity&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;var&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstSteps&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OfType&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;BatchLoadStep&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;()&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;FirstOrDefault&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;!=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;step&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Entities&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;OfType&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;T&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;null&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;int&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;FailedOperationCount&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;get&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstFaildOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: white;&quot;&gt;Count&lt;/span&gt;;&amp;nbsp;}&amp;nbsp;}&lt;br /&gt; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: #b8d7a3;&quot;&gt;IEnumerable&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #4ec9b0;&quot;&gt;LoadOperation&lt;/span&gt;&lt;span style=&quot;color: #b4b4b4;&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;FailedOperations&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;get&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color: #569cd6;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: white;&quot;&gt;_lstFaildOperation&lt;/span&gt;;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;span style=&quot;color: #9b9b9b;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#endregion&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/8788826815563116320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2013/09/silverlight-ria-service.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8788826815563116320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8788826815563116320'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2013/09/silverlight-ria-service.html' title='Silverlight RIA service, DomainContextBatchLoader'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-446254396208776872</id><published>2013-01-24T17:30:00.000-08:00</published><updated>2013-01-24T17:30:10.663-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Apple Style Scroll bar in WPF</title><content type='html'>I am working on a WPF application recently, created a Apple style scrollbar.&lt;br /&gt;Here is the code, hope it will be useful. This version had been tailored to meet my requirement. &amp;nbsp;after apply it to a listbox, it looks like the following.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-CzCYjZfpb6s/UQHf8d0HB1I/AAAAAAAACyA/2iV7MIaY90w/s1600/ScreenHunter_14+Jan.+25+12.28.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-CzCYjZfpb6s/UQHf8d0HB1I/AAAAAAAACyA/2iV7MIaY90w/s320/ScreenHunter_14+Jan.+25+12.28.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Also there is very good article &amp;nbsp;&lt;a href=&quot;http://www.codeproject.com/Articles/37366/Styling-A-ScrollViewer-Scrollbar-In-WPF&quot; target=&quot;_blank&quot;&gt;http://www.codeproject.com/Articles/37366/Styling-A-ScrollViewer-Scrollbar-In-WPF&lt;/a&gt;&amp;nbsp;explain the structure of Scrollbar and how to change it.&lt;br /&gt;&lt;pre style=&quot;background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: 100%; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;&quot;&gt;&lt;code style=&quot;color: black; word-wrap: normal;&quot;&gt;1:  &amp;lt;SolidColorBrush x:Key=&quot;ScrollBarDisabledBackground&quot; Color=&quot;#F4F4F4&quot;/&amp;gt;  &lt;br /&gt;2:      &amp;lt;Style x:Key=&quot;VerticalScrollBarPageButton&quot; TargetType=&quot;{x:Type RepeatButton}&quot;&amp;gt;  &lt;br /&gt;3:        &amp;lt;Setter Property=&quot;OverridesDefaultStyle&quot; Value=&quot;true&quot;/&amp;gt;  &lt;br /&gt;4:        &amp;lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot;/&amp;gt;  &lt;br /&gt;5:        &amp;lt;Setter Property=&quot;Focusable&quot; Value=&quot;false&quot;/&amp;gt;  &lt;br /&gt;6:        &amp;lt;Setter Property=&quot;IsTabStop&quot; Value=&quot;false&quot;/&amp;gt;  &lt;br /&gt;7:        &amp;lt;Setter Property=&quot;Template&quot;&amp;gt;  &lt;br /&gt;8:          &amp;lt;Setter.Value&amp;gt;  &lt;br /&gt;9:            &amp;lt;ControlTemplate TargetType=&quot;{x:Type RepeatButton}&quot;&amp;gt;  &lt;br /&gt;10:              &amp;lt;Rectangle Fill=&quot;{TemplateBinding Background}&quot; Height=&quot;{TemplateBinding Height}&quot; Width=&quot;{TemplateBinding Width}&quot;/&amp;gt;  &lt;br /&gt;11:            &amp;lt;/ControlTemplate&amp;gt;  &lt;br /&gt;12:          &amp;lt;/Setter.Value&amp;gt;  &lt;br /&gt;13:        &amp;lt;/Setter&amp;gt;  &lt;br /&gt;14:      &amp;lt;/Style&amp;gt;  &lt;br /&gt;15:      &amp;lt;Style x:Key=&quot;ScrollBarThumb&quot; TargetType=&quot;{x:Type Thumb}&quot;&amp;gt;  &lt;br /&gt;16:        &amp;lt;Setter Property=&quot;OverridesDefaultStyle&quot; Value=&quot;true&quot;/&amp;gt;  &lt;br /&gt;17:        &amp;lt;Setter Property=&quot;IsTabStop&quot; Value=&quot;false&quot;/&amp;gt;  &lt;br /&gt;18:        &amp;lt;Setter Property=&quot;Template&quot;&amp;gt;  &lt;br /&gt;19:          &amp;lt;Setter.Value&amp;gt;  &lt;br /&gt;20:            &amp;lt;ControlTemplate TargetType=&quot;{x:Type Thumb}&quot;&amp;gt;  &lt;br /&gt;21:              &amp;lt;Border Background=&quot;#FF868686&quot; BorderThickness=&quot;0,0,1,0&quot; Height=&quot;Auto&quot; CornerRadius=&quot;4&quot; /&amp;gt;  &lt;br /&gt;22:            &amp;lt;/ControlTemplate&amp;gt;  &lt;br /&gt;23:          &amp;lt;/Setter.Value&amp;gt;  &lt;br /&gt;24:        &amp;lt;/Setter&amp;gt;  &lt;br /&gt;25:      &amp;lt;/Style&amp;gt;  &lt;br /&gt;26:      &amp;lt;Style x:Key=&quot;HorizontalScrollStyle&quot; TargetType=&quot;{x:Type ScrollBar}&quot;&amp;gt;  &lt;br /&gt;27:        &amp;lt;Setter Property=&quot;Background&quot; Value=&quot;Transparent&quot;/&amp;gt;  &lt;br /&gt;28:        &amp;lt;Setter Property=&quot;Template&quot;&amp;gt;  &lt;br /&gt;29:          &amp;lt;Setter.Value&amp;gt;  &lt;br /&gt;30:            &amp;lt;ControlTemplate TargetType=&quot;{x:Type ScrollBar}&quot;&amp;gt;  &lt;br /&gt;31:              &amp;lt;Grid x:Name=&quot;Bg&quot; Background=&quot;{TemplateBinding Background}&quot; Height=&quot;10&quot; SnapsToDevicePixels=&quot;true&quot;&amp;gt;  &lt;br /&gt;32:                &amp;lt;Grid.RowDefinitions&amp;gt;  &lt;br /&gt;33:                  &amp;lt;RowDefinition /&amp;gt;  &lt;br /&gt;34:                &amp;lt;/Grid.RowDefinitions&amp;gt;  &lt;br /&gt;35:                &amp;lt;Track x:Name=&quot;PART_Track&quot; IsDirectionReversed=&quot;true&quot; IsEnabled=&quot;{TemplateBinding IsMouseOver}&quot;&amp;gt;  &lt;br /&gt;36:                  &amp;lt;Track.DecreaseRepeatButton&amp;gt;  &lt;br /&gt;37:                    &amp;lt;RepeatButton Command=&quot;{x:Static ScrollBar.PageUpCommand}&quot; Style=&quot;{StaticResource VerticalScrollBarPageButton}&quot;/&amp;gt;  &lt;br /&gt;38:                  &amp;lt;/Track.DecreaseRepeatButton&amp;gt;  &lt;br /&gt;39:                  &amp;lt;Track.IncreaseRepeatButton&amp;gt;  &lt;br /&gt;40:                    &amp;lt;RepeatButton Command=&quot;{x:Static ScrollBar.PageDownCommand}&quot; Style=&quot;{StaticResource VerticalScrollBarPageButton}&quot;/&amp;gt;  &lt;br /&gt;41:                  &amp;lt;/Track.IncreaseRepeatButton&amp;gt;  &lt;br /&gt;42:                  &amp;lt;Track.Thumb&amp;gt;  &lt;br /&gt;43:                    &amp;lt;Thumb Style=&quot;{StaticResource ScrollBarThumb}&quot; Cursor=&quot;Hand&quot;/&amp;gt;  &lt;br /&gt;44:                  &amp;lt;/Track.Thumb&amp;gt;  &lt;br /&gt;45:                &amp;lt;/Track&amp;gt;  &lt;br /&gt;46:              &amp;lt;/Grid&amp;gt;  &lt;br /&gt;47:              &amp;lt;ControlTemplate.Triggers&amp;gt;  &lt;br /&gt;48:                &amp;lt;Trigger Property=&quot;IsEnabled&quot; Value=&quot;false&quot;&amp;gt;  &lt;br /&gt;49:                  &amp;lt;Setter Property=&quot;Background&quot; TargetName=&quot;Bg&quot; Value=&quot;{StaticResource ScrollBarDisabledBackground}&quot;/&amp;gt;  &lt;br /&gt;50:                &amp;lt;/Trigger&amp;gt;  &lt;br /&gt;51:              &amp;lt;/ControlTemplate.Triggers&amp;gt;  &lt;br /&gt;52:            &amp;lt;/ControlTemplate&amp;gt;  &lt;br /&gt;53:          &amp;lt;/Setter.Value&amp;gt;  &lt;br /&gt;54:        &amp;lt;/Setter&amp;gt;  &lt;br /&gt;55:      &amp;lt;/Style&amp;gt;  &lt;br /&gt;56:      &amp;lt;Style x:Key=&quot;AppleStyleVerticalScrollBarStyle&quot; TargetType=&quot;{x:Type ScrollBar}&quot;&amp;gt;  &lt;br /&gt;57:        &amp;lt;Setter Property=&quot;Template&quot;&amp;gt;  &lt;br /&gt;58:          &amp;lt;Setter.Value&amp;gt;  &lt;br /&gt;59:            &amp;lt;ControlTemplate TargetType=&quot;{x:Type ScrollBar}&quot;&amp;gt;  &lt;br /&gt;60:              &amp;lt;Grid x:Name=&quot;Bg&quot; SnapsToDevicePixels=&quot;true&quot; Width=&quot;10&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0&quot;&amp;gt;  &lt;br /&gt;61:                &amp;lt;Grid.RowDefinitions&amp;gt;  &lt;br /&gt;62:                  &amp;lt;RowDefinition /&amp;gt;  &lt;br /&gt;63:                &amp;lt;/Grid.RowDefinitions&amp;gt;  &lt;br /&gt;64:                &amp;lt;Track x:Name=&quot;PART_Track&quot; IsDirectionReversed=&quot;true&quot; IsEnabled=&quot;{TemplateBinding IsMouseOver}&quot;&amp;gt;  &lt;br /&gt;65:                  &amp;lt;Track.DecreaseRepeatButton&amp;gt;  &lt;br /&gt;66:                    &amp;lt;RepeatButton Command=&quot;{x:Static ScrollBar.PageUpCommand}&quot; Style=&quot;{StaticResource VerticalScrollBarPageButton}&quot; /&amp;gt;  &lt;br /&gt;67:                  &amp;lt;/Track.DecreaseRepeatButton&amp;gt;  &lt;br /&gt;68:                  &amp;lt;Track.IncreaseRepeatButton&amp;gt;  &lt;br /&gt;69:                    &amp;lt;RepeatButton Command=&quot;{x:Static ScrollBar.PageDownCommand}&quot; Style=&quot;{StaticResource VerticalScrollBarPageButton}&quot;/&amp;gt;  &lt;br /&gt;70:                  &amp;lt;/Track.IncreaseRepeatButton&amp;gt;  &lt;br /&gt;71:                  &amp;lt;Track.Thumb&amp;gt;  &lt;br /&gt;72:                    &amp;lt;Thumb Style=&quot;{DynamicResource ScrollBarThumb}&quot; Cursor=&quot;Hand&quot;/&amp;gt;  &lt;br /&gt;73:                  &amp;lt;/Track.Thumb&amp;gt;  &lt;br /&gt;74:                &amp;lt;/Track&amp;gt;  &lt;br /&gt;75:              &amp;lt;/Grid&amp;gt;  &lt;br /&gt;76:            &amp;lt;/ControlTemplate&amp;gt;  &lt;br /&gt;77:          &amp;lt;/Setter.Value&amp;gt;  &lt;br /&gt;78:        &amp;lt;/Setter&amp;gt;  &lt;br /&gt;79:      &amp;lt;/Style&amp;gt;  &lt;br /&gt;80:      &amp;lt;ControlTemplate x:Key=&quot;AppleStyleScrollBarStyle&quot; TargetType=&quot;{x:Type ScrollViewer}&quot;&amp;gt;  &lt;br /&gt;81:        &amp;lt;Grid x:Name=&quot;Grid&quot; Background=&quot;{TemplateBinding Background}&quot;&amp;gt;  &lt;br /&gt;82:          &amp;lt;Grid.ColumnDefinitions&amp;gt;  &lt;br /&gt;83:            &amp;lt;ColumnDefinition Width=&quot;*&quot;/&amp;gt;  &lt;br /&gt;84:            &amp;lt;ColumnDefinition Width=&quot;Auto&quot;/&amp;gt;  &lt;br /&gt;85:          &amp;lt;/Grid.ColumnDefinitions&amp;gt;  &lt;br /&gt;86:          &amp;lt;Grid.RowDefinitions&amp;gt;  &lt;br /&gt;87:            &amp;lt;RowDefinition Height=&quot;*&quot;/&amp;gt;  &lt;br /&gt;88:            &amp;lt;RowDefinition Height=&quot;Auto&quot;/&amp;gt;  &lt;br /&gt;89:          &amp;lt;/Grid.RowDefinitions&amp;gt;  &lt;br /&gt;90:          &amp;lt;Rectangle x:Name=&quot;Corner&quot; Grid.Column=&quot;1&quot; Fill=&quot;{x:Null}&quot; Grid.Row=&quot;1&quot;/&amp;gt;  &lt;br /&gt;91:          &amp;lt;ScrollContentPresenter x:Name=&quot;PART_ScrollContentPresenter&quot; CanContentScroll=&quot;{TemplateBinding CanContentScroll}&quot;   &lt;br /&gt;92:                      CanHorizontallyScroll=&quot;False&quot; CanVerticallyScroll=&quot;False&quot;   &lt;br /&gt;93:                      ContentTemplate=&quot;{TemplateBinding ContentTemplate}&quot;   &lt;br /&gt;94:                      Content=&quot;{TemplateBinding Content}&quot; Grid.Column=&quot;0&quot;   &lt;br /&gt;95:                      Margin=&quot;{TemplateBinding Padding}&quot; Grid.Row=&quot;0&quot;/&amp;gt;  &lt;br /&gt;96:          &amp;lt;ScrollBar x:Name=&quot;PART_VerticalScrollBar&quot; Visibility=&quot;{TemplateBinding ComputedVerticalScrollBarVisibility}&quot;   &lt;br /&gt;97:              AutomationProperties.AutomationId=&quot;VerticalScrollBar&quot; Cursor=&quot;Arrow&quot; Grid.Column=&quot;1&quot;   &lt;br /&gt;98:              Maximum=&quot;{TemplateBinding ScrollableHeight}&quot; Minimum=&quot;0&quot; Grid.Row=&quot;0&quot;   &lt;br /&gt;99:              Value=&quot;{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}&quot;   &lt;br /&gt;100:              ViewportSize=&quot;{TemplateBinding ViewportHeight}&quot; Style=&quot;{DynamicResource AppleStyleVerticalScrollBarStyle}&quot;   &lt;br /&gt;101:                Background=&quot;{x:Null}&quot; Width=&quot;Auto&quot; Margin=&quot;0&quot;/&amp;gt;  &lt;br /&gt;102:          &amp;lt;ScrollBar x:Name=&quot;PART_HorizontalScrollBar&quot; Visibility=&quot;{TemplateBinding ComputedHorizontalScrollBarVisibility}&quot;   &lt;br /&gt;103:              AutomationProperties.AutomationId=&quot;HorizontalScrollBar&quot; Cursor=&quot;Arrow&quot; Grid.Column=&quot;0&quot;   &lt;br /&gt;104:              Maximum=&quot;{TemplateBinding ScrollableWidth}&quot; Minimum=&quot;0&quot; Orientation=&quot;Horizontal&quot; Grid.Row=&quot;1&quot;   &lt;br /&gt;105:              Value=&quot;{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}&quot;   &lt;br /&gt;106:              ViewportSize=&quot;{TemplateBinding ViewportWidth}&quot; Style=&quot;{DynamicResource HorizontalScrollStyle}&quot;/&amp;gt;  &lt;br /&gt;107:        &amp;lt;/Grid&amp;gt;  &lt;br /&gt;108:      &amp;lt;/ControlTemplate&amp;gt;  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/446254396208776872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2013/01/apple-style-scroll-bar-in-wpf.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/446254396208776872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/446254396208776872'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2013/01/apple-style-scroll-bar-in-wpf.html' title='Apple Style Scroll bar in WPF'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-CzCYjZfpb6s/UQHf8d0HB1I/AAAAAAAACyA/2iV7MIaY90w/s72-c/ScreenHunter_14+Jan.+25+12.28.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-8583643426553649868</id><published>2012-10-25T04:39:00.001-07:00</published><updated>2012-10-25T04:39:42.305-07:00</updated><title type='text'>A Very good article regarding deferred execution and lazy loading</title><content type='html'>http://www.rizalalmashoor.com/blog/linq-to-entities-deferred-execution-and-lazy-loading/</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/8583643426553649868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/10/a-very-good-article-regarding-deferred.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8583643426553649868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8583643426553649868'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/10/a-very-good-article-regarding-deferred.html' title='A Very good article regarding deferred execution and lazy loading'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-2521261719932225805</id><published>2012-08-01T06:37:00.002-07:00</published><updated>2012-08-04T22:18:01.479-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BizTalk"/><title type='text'>must receive before sending a fault message on an implemented port</title><content type='html'>As a .net developer , just moved to BizTalk field, &amp;nbsp;I came across a lot issues in the last couple month when our project start to use BizTalk intensively.&lt;br /&gt;&lt;br /&gt;As the title, when I was trying to implement a very simple sample , &amp;nbsp;I got this error .&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-Rg312L9vESg/UBkrnM8fxhI/AAAAAAAACwQ/rWUwwn9y1IE/s1600/1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-Rg312L9vESg/UBkrnM8fxhI/AAAAAAAACwQ/rWUwwn9y1IE/s1600/1.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I setup a port which have request/response/fault, refer to the above snapshot. &amp;nbsp;in my orchestration, I implement very simple logic.&lt;br /&gt;1.receive a message from the request port.&lt;br /&gt;2.read the information from request, and then based on the message type specified in the request, dynamically transform the request to a response message.&lt;br /&gt;3.send the response back to client.&lt;br /&gt;4.if there are any error/exception happens, send a fault back to client.&lt;br /&gt;refer to the following snapshot.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-Ndz7QzM5x_U/UBksiVh3DRI/AAAAAAAACwY/qZSPzDSa5m0/s1600/2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-Ndz7QzM5x_U/UBksiVh3DRI/AAAAAAAACwY/qZSPzDSa5m0/s320/2.PNG&quot; width=&quot;229&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;it is quite simple logic , but when I compile it, I get the following two errors.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;1.must receive before sending a fault message on an implemented port&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;2.incomplete requestresponse operation; missing &#39;send&#39;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;By just simply look at the orchestration, I didn&#39;t aware anything is wrong, I do have a receive shape at the beginning , also I do have a send shape at the end of the orchestration,thus I refer to my good friend google for answers. &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;It is quite hard to find a solution for this easily , I think this might be too easy, too basic, thus no one bother to talk about it. &amp;nbsp;but I do find some clues, When Visual Studio compile the solution , it will try to make sure every logic path is correct. &amp;nbsp;Then I go back to visit my orchestration, assume we get an exception in the scope , during the dynamic mapping. &amp;nbsp;here is the flow.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;1.receive a message from the port.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;2.construct the response message.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;3.do the dynamic mapping. here we get an exception.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;4.it jump to exception handling.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;5.construct fault message&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;6.send the fault message back to client.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;7 then the flow continue to send a response back.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;You see the issue, after you send a fault message back to client, the whole channel had been faulted, how could we send &amp;nbsp;a response back client again?&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In order to resolve this issue, I simple put a terminate shape after send the fault message back , then it compiles and works smoothly. &amp;nbsp;The orchestration looks like this.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-6FyRDmRJlV0/UBkws1kjJhI/AAAAAAAACwo/HanivWZJolY/s1600/3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://2.bp.blogspot.com/-6FyRDmRJlV0/UBkws1kjJhI/AAAAAAAACwo/HanivWZJolY/s320/3.PNG&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;It puzzled me a while as new BizTalk developer. when you get it , it is so easy.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/2521261719932225805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/08/must-receive-before-sending-fault.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2521261719932225805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2521261719932225805'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/08/must-receive-before-sending-fault.html' title='must receive before sending a fault message on an implemented port'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Rg312L9vESg/UBkrnM8fxhI/AAAAAAAACwQ/rWUwwn9y1IE/s72-c/1.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-5515033819713382879</id><published>2012-03-11T21:58:00.001-07:00</published><updated>2012-03-11T21:58:35.375-07:00</updated><title type='text'>AQGridView, load AQGridCell from xib file</title><content type='html'>Recently I am working on an app , which will need to use &lt;a href=&quot;https://github.com/AlanQuatermain/AQGridView&quot; target=&quot;_blank&quot;&gt;AQGridView&lt;/a&gt;, which will allow me to present my content in a grid format.&lt;br /&gt;Like the UITableView, we need to implement a class to draw the cell content, and this class should inherit from AQGridCell. &amp;nbsp;the downside of this method is , we need to draw the whole cell UI use code, if it is simple cell , that should be fine. but I don&#39;t want to write too much code which can be done with a xib file. so I was thinking how to load a xib file on the fly. it does take me sometime to figure it out, thus I write it down, hope someone else still want to do the same thing can benefit from this, also for myself , if later on I need to implement similar features, I can come back to read it, my long term memory is bad.&lt;br /&gt;&lt;br /&gt;So here it is.&lt;br /&gt;First of all, I create a class and inherit it from UIView,&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;#import &lt;/span&gt;&amp;lt;UIKit/UIKit.h&amp;gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;span class=&quot;s2&quot;&gt;@interface&lt;/span&gt; TVViewCellWithUI : &lt;span class=&quot;s3&quot;&gt;UIView&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;Then I create a xib file call it , TVViewCellWithUI.xib, pretty simple , put one UIImagView and a couple labels on it,&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-IAe30tP_wqw/T11_A1mWJjI/AAAAAAAABwk/oKXn25GBgqk/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-IAe30tP_wqw/T11_A1mWJjI/AAAAAAAABwk/oKXn25GBgqk/s1600/1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;On the view, I set the view is &quot;TVViewCellWithUI&quot;&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-nd-fk3DeQRw/T11_R1OsncI/AAAAAAAABws/b9fHoI950PA/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-nd-fk3DeQRw/T11_R1OsncI/AAAAAAAABws/b9fHoI950PA/s1600/2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Then I can create outlet, actions stuff with drag and drop in TVViewCellWithUI class.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-cWN4dJPbeG8/T11_1AUgEiI/AAAAAAAABw0/Ru-thlTg7eE/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;130&quot; src=&quot;http://2.bp.blogspot.com/-cWN4dJPbeG8/T11_1AUgEiI/AAAAAAAABw0/Ru-thlTg7eE/s320/3.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;then , the tricky part is , how I create the AQGridCell , &amp;nbsp;refer to the following snapshot.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-Hp-czsp-NyU/T12AaLzNY9I/AAAAAAAABw8/LN1r0sxDysQ/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; src=&quot;http://1.bp.blogspot.com/-Hp-czsp-NyU/T12AaLzNY9I/AAAAAAAABw8/LN1r0sxDysQ/s400/4.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;so what I did is , first of all I create an instance of TVViewCellWithUI and then use NSBundle to load the TVViewCellWithUI xib file dynamically. &amp;nbsp;after that , assign the first element of the array to TVViewCellWithUI instance.&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;        &lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;TVViewCellWithUI&lt;span class=&quot;s1&quot;&gt; *vClass = [[&lt;/span&gt;TVViewCellWithUI&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;alloc&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;NSArray&lt;span class=&quot;s1&quot;&gt;* array = [[&lt;/span&gt;NSBundle&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;mainBundle&lt;span class=&quot;s1&quot;&gt;] &lt;/span&gt;loadNibNamed&lt;span class=&quot;s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;@&quot;TVViewCellWithUI&quot;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;owner&lt;span class=&quot;s1&quot;&gt;:vClass &lt;/span&gt;options&lt;span class=&quot;s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p3&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vClass = [array &lt;span class=&quot;s2&quot;&gt;objectAtIndex&lt;/span&gt;:&lt;span class=&quot;s5&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;Note,&amp;nbsp;NSArray&lt;span class=&quot;s1&quot;&gt;* array = [[&lt;/span&gt;NSBundle&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&lt;/span&gt;mainBundle&lt;span class=&quot;s1&quot;&gt;]&amp;nbsp;&lt;/span&gt;loadNibNamed&lt;span class=&quot;s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;@&quot;TVViewCellWithUI&quot;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp;&lt;/span&gt;owner&lt;span class=&quot;s1&quot;&gt;:vClass&amp;nbsp;&lt;/span&gt;options&lt;span class=&quot;s1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s4&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;]; the type of owner parameter should match with the type of the root view which we specified in the xib file, in my cause it is TVViewCellWithUI.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;if a different type of instance has been passed in as the owner, you will get unexpected result, for me , the function will stuck there without return control to you.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;after all these , create an instance of AQGridViewCell , and also add the TVViewCellWithUI into&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;filledCell = [[&lt;span class=&quot;s1&quot;&gt;AQGridViewCell&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;alloc&lt;/span&gt;] &lt;span class=&quot;s1&quot;&gt;initWithFrame&lt;/span&gt;:vClass.&lt;span class=&quot;s2&quot;&gt;frame&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;reuseIdentifier&lt;/span&gt;:FilledCellIdentifier];&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [filledCell.&lt;span class=&quot;s1&quot;&gt;contentView&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;addSubview&lt;/span&gt;:vClass];&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;In this way, we can take advantage of the xib file which we can easily change the UI without writing extra code.&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/5515033819713382879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/03/aqgridview-load-aqgridcell-from-xib.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5515033819713382879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5515033819713382879'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/03/aqgridview-load-aqgridcell-from-xib.html' title='AQGridView, load AQGridCell from xib file'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-IAe30tP_wqw/T11_A1mWJjI/AAAAAAAABwk/oKXn25GBgqk/s72-c/1.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-3856421250562473854</id><published>2012-02-02T16:38:00.000-08:00</published><updated>2012-02-02T16:38:57.976-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BizTalk"/><category scheme="http://www.blogger.com/atom/ns#" term="Map"/><title type='text'>In BizTalk map, use funtoid to skip the output element for some values.</title><content type='html'>We are using BizTalk 2010 in our project, &amp;nbsp; In the source schema from our origination system, they use string type to represent datetime, and when the source system can&#39;t provide it, for example, when the source system is experiencing some technical difficulties,it use dash instead, thus we need to handle this special character.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the destination schema of map , we already set the field to be nullable, so what we need to implement in the map is, when the datetime is not dash, we convert the datetime, and set to the destination element, when it is dash, we need to keep skip it , and leave the destination element untouched.&lt;/div&gt;&lt;div&gt;Here is how I make it happen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-CX9KMHlRRn4/Tysq4ZNb-QI/AAAAAAAABnE/7YWL7Nb35dk/s1600/2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;115&quot; src=&quot;http://4.bp.blogspot.com/-CX9KMHlRRn4/Tysq4ZNb-QI/AAAAAAAABnE/7YWL7Nb35dk/s320/2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;ol&gt;&lt;li style=&quot;text-align: left;&quot;&gt;Use a Logical functoid, to make sure the value is not dash.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-5GqSbKMSB18/TysrUmPERDI/AAAAAAAABnM/BwcvQRG5cfc/s1600/3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-5GqSbKMSB18/TysrUmPERDI/AAAAAAAABnM/BwcvQRG5cfc/s320/3.png&quot; width=&quot;291&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;2.Use a value map functoid.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-0JZoN46nmts/Tysrt9d0Q2I/AAAAAAAABnY/ltQ9DM5ThJM/s1600/4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-0JZoN46nmts/Tysrt9d0Q2I/AAAAAAAABnY/ltQ9DM5ThJM/s320/4.png&quot; width=&quot;291&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;3.Then send the value to the script functoid to convert the value , and finally map it to the destination element.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In this way, if the source value is dash, then the destination element will not be assigned any values.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/3856421250562473854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/02/in-biztalk-map-use-funtoid-to-skip.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3856421250562473854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3856421250562473854'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/02/in-biztalk-map-use-funtoid-to-skip.html' title='In BizTalk map, use funtoid to skip the output element for some values.'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-CX9KMHlRRn4/Tysq4ZNb-QI/AAAAAAAABnE/7YWL7Nb35dk/s72-c/2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-2636540893446158086</id><published>2012-01-29T20:42:00.000-08:00</published><updated>2012-01-29T20:42:02.439-08:00</updated><title type='text'>BizTalk tricks</title><content type='html'>I was making a very simple BizTalk map changes last Friday.&lt;br /&gt;&lt;br /&gt;we have a bunch of maps in our solution, which just convert one schema to another. &amp;nbsp;In one of the map, a couple of the values had been hard coded using string concatenate functoid. &amp;nbsp;but unfortunately , our vendor required us to change the values before it go live. So I just open the map and change the value, then checked in.&lt;br /&gt;&lt;br /&gt;But after I deploy it to the server, it turns out the map doesn&#39;t pick up the value I had changed in the map. thus it still using the old values. &amp;nbsp;I was called up to fix it, obviously, VS don&#39;t think I made changes to the map , thus it doesn&#39;t compile it correctly, so I end up make some link changes in the map to make sure VS2010 pick up the changes. and then it is fixed.&lt;br /&gt;&lt;br /&gt;Also , in order to avoid similar changes in the future, I create a functoid to read the values from the configuration file. &amp;nbsp;another strange thing happened, I put the function in a separate project, I deployed to GAC, but unfortunately , when I try to pick up the functoid from the map, it can&#39;t find the functoid which I added just now.&lt;br /&gt;&lt;br /&gt;After I close the VS2010 and open it again, it found the new function correctly....&lt;br /&gt;&lt;br /&gt;So in a conclusion&lt;br /&gt;1. if you only make some value changes in the functoid of your map , please make sure VS2010 really had picked up the changes, make some link change should do it.&lt;br /&gt;2. if you add new functoid &amp;nbsp;and VS2010 failed to pick it up , please restart your VS2010 , this might save you.&lt;br /&gt;&lt;br /&gt;BizTalk is powerful , but the development is not that user friendly.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/2636540893446158086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/01/biztalk-tricks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2636540893446158086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2636540893446158086'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/01/biztalk-tricks.html' title='BizTalk tricks'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-3215290159316890976</id><published>2012-01-26T22:00:00.000-08:00</published><updated>2012-01-26T22:00:07.380-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS5"/><title type='text'>UITableView grouped</title><content type='html'>When I am trying to implement a window under IOS, it is quite simple Table View, but I want it to have round corner, the grouped style UITableView, but some how I can&#39;t make that happen even after I set the TableView&#39;s style to &quot;Group&quot;, but it still display as a plain style.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-Ktv6oGqzZXc/TyI7TimX6nI/AAAAAAAABms/QzZcAQR6eUE/s1600/Screen+Shot+2012-01-27+at+4.48.26+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;60&quot; src=&quot;http://2.bp.blogspot.com/-Ktv6oGqzZXc/TyI7TimX6nI/AAAAAAAABms/QzZcAQR6eUE/s320/Screen+Shot+2012-01-27+at+4.48.26+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;After some investigation , I found out it is to do with the way I create the view object.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was using something like the following to create the table view.&amp;nbsp;&lt;/div&gt;&lt;div&gt;TableView *view = [TableView alloc] init];&lt;/div&gt;&lt;div&gt;In this way, the UITableView&#39;s style will always be set to UITableViewStylePlain, the correct way to do it is&amp;nbsp;&lt;/div&gt;&lt;div&gt;TableView *view = [TableView alloc] initWithStyle:UITableViewStyleGrouped];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;or TableView *view = [TableView alloc]&amp;nbsp;initWithNibName:@&quot;MyTableView&quot; bundle:nil];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It is a simple issue, but just write down in case somebody else is still wandering... The final result should looks like the following.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-FVG6IsrDYpw/TyI9UQFJ3BI/AAAAAAAABm0/qKGJk2YkDGM/s1600/1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-FVG6IsrDYpw/TyI9UQFJ3BI/AAAAAAAABm0/qKGJk2YkDGM/s320/1.png&quot; width=&quot;280&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/3215290159316890976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/01/uitableview-grouped.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3215290159316890976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3215290159316890976'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2012/01/uitableview-grouped.html' title='UITableView grouped'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-Ktv6oGqzZXc/TyI7TimX6nI/AAAAAAAABms/QzZcAQR6eUE/s72-c/Screen+Shot+2012-01-27+at+4.48.26+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-6348328022276461113</id><published>2011-11-02T15:53:00.000-07:00</published><updated>2011-11-02T15:53:45.922-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS5 RESTful service authentication"/><title type='text'>Calling RESTful service under IOS5 failed with 401 error</title><content type='html'>&lt;div&gt;Recently, we upgrade our iPad to IOS5, and xCode to 4.2 version, &amp;nbsp;after we done that I came across an issue.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In our iPad application, we are calling the RESTful service on our server side, and we are using SSL and basic authentication, for most of the service call, it works fine, only two of the web services, the calls made from iPad application failed with 401 authentication error.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The strange thing is , under IOS4.3.5 it works fine, only IOS 5 failed.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;after some investigation, I find out the RESTful service on our server, these two service that failed with 401, the url template is like /xxx/aaa/. while on the iPad application we are calling it as /xxx/aaa.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When I open Chrome and monitor the network request, I can actually see if we call it as /xxx/aaa, it get and HTTP 307 first, and redirect to /xxx/aaa/.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For some reason , IOS4 it works cause the basic authentication will be carry over to the next redirect request. while on IOS5, basic authentication will be dropped on the coming redirect request. that&#39;s why my service call fail, I change the code to call service like /xxx/aaa/ , then it all works.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;write down this just in case some other people also experiencing the same issue, so they can save a little bit time.&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/6348328022276461113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/11/calling-restful-service-under-ios5.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/6348328022276461113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/6348328022276461113'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/11/calling-restful-service-under-ios5.html' title='Calling RESTful service under IOS5 failed with 401 error'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-4422074121815663874</id><published>2011-06-12T00:33:00.000-07:00</published><updated>2011-06-12T00:33:21.371-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Email"/><title type='text'>How to talk to Exchange Server using .net code.</title><content type='html'>Recently, I took a task to develop a tool , which will be required to access a mailbox, and pull email from there automatically and periodically. the situation is , one of our customer, which is using our financial service, when consumer go to their website or store, and want to buy their product using finance , they will ask consumer to fill in a form, and then send the information to us by email.&lt;br /&gt;&lt;br /&gt;In the mean time, a team had been setup in house to specifically to handle those email, as you know, this is not a good solution, thus, we would develop a series of web service and try to avoid sending email, but as a matter of fact, there is a lot problem with the security setting, firewall stuff, which apparently block the web service. &amp;nbsp;In order to test the web service, they decide to send us the xml request through email as well.&lt;br /&gt;&lt;br /&gt;Thus my tool will be required to pull those email &amp;nbsp;from a mailbox, which email body is the xml request, and then send route the xml to our web service, in this way, we can test our web service before the infrastructure issue is resolved.&lt;br /&gt;&lt;br /&gt;Originally I was thinking, it is quite easy, I can use POP3 to access my mailbox, but it is quite&amp;nbsp;frustrating&amp;nbsp;, cause we are using Exchange server 2010, and POP3 had been turned off. &amp;nbsp;but after some investigation , I found out , that in Exchange Server 2010, it provide web service, as well as some SDK, thus application can use these SDK to access the mailbox.&lt;br /&gt;&lt;br /&gt;If you also need to interactive with your Exchange mailbox, you can think about to use this as well, it is pretty easy.&lt;br /&gt;&lt;br /&gt;The SDK is available at the following location.&lt;br /&gt;&lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1&quot;&gt;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I just want to show you how easy to access your email box using C# code.&lt;br /&gt;Connect to the mail server:&lt;br /&gt;&lt;br /&gt;ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);&lt;br /&gt;service.Credentials = new WebCredentials(&quot;johnny.luo&quot;, &quot;password&quot;, &quot;domain&quot;);&lt;br /&gt;service.AutodiscoverUrl(&quot;johnny.luo@*******.com.au&quot;);&lt;br /&gt;go through emails&lt;br /&gt;&lt;br /&gt;ItemView iv = new ItemView(200);&lt;br /&gt;FindItemsResults&amp;lt;Item&amp;gt; result = service.FindItems(fi, iv);&lt;br /&gt;&lt;br /&gt;send email:&lt;br /&gt;&lt;br /&gt;EmailMessage msg = new EmailMessage(service);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.Subject = string.Format(&quot;Content {0}&quot;, ex.Message);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.ToRecipients.Add(&quot;johnny.luo@******.com.au&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var att = msg.Attachments.AddItemAttachment&amp;lt;Item&amp;gt;();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att.Name = &quot;XML email&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att.Item.MimeContent = xmlItem.EmailItem.MimeContent;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var att1 = msg.Attachments.AddItemAttachment&amp;lt;Item&amp;gt;();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att1.Name = &quot;Plain Text email&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; att1.Item.MimeContent = query.EmailItem.MimeContent;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; msg.SendAndSaveCopy();</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/4422074121815663874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/06/how-to-talk-to-exchange-server-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/4422074121815663874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/4422074121815663874'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/06/how-to-talk-to-exchange-server-using.html' title='How to talk to Exchange Server using .net code.'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-418162148357774172</id><published>2011-04-03T17:37:00.000-07:00</published><updated>2011-04-03T17:37:10.463-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DataGrid"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>WPF DataGrid GotChas</title><content type='html'>I am intensively using WPF recently, this post explain quite a lot the issues I came across in the past two weeks.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://blogs.msdn.com/b/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx&quot;&gt;http://blogs.msdn.com/b/vinsibal/archive/2009/04/07/5-random-gotchas-with-the-wpf-datagrid.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you want to use DataGrid in WPF , recommend you to read it.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/418162148357774172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/04/wpf-datagrid-gotchas.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/418162148357774172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/418162148357774172'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/04/wpf-datagrid-gotchas.html' title='WPF DataGrid GotChas'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-8945297573135373084</id><published>2011-03-26T19:39:00.000-07:00</published><updated>2011-03-26T19:39:22.727-07:00</updated><title type='text'>In GDI+ how to draw a text vertically.</title><content type='html'>Two weeks ago , I moved to a new company, and become very busy, to be honest, at Ninemsn, the culture is quite relax, not too much pressure, while in my new company, cause the team is small, I need to do most of the design and development, so quite busy, that&#39;s why I didn&#39;t get time to update my blog.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;As my first assignment in this company is to develop a chart control, which need to support line chart, pie chart, stack bar chart etc. &amp;nbsp;At this point , some people might ask , why not just find one from the market? &amp;nbsp;well, that&#39;s a very good question, I ask them as well, but the answer is , their chart requirement is quite unique , &amp;nbsp; for example, they need a kind of stack bar chart. &amp;nbsp;all the others are standard, while the width of the stack bar should represent the production, that means , if a company, their production is high, &amp;nbsp;the width of the bar should represent it. &amp;nbsp;to be honest, I can&#39;t find a control from the market can meet this requirement without any funky customization. &amp;nbsp;furthermore, their want the chart can be export to word natively, when I say natively &amp;nbsp;means, the chart can be edit in word, cause most chart control currently, they can be export to word as an image, that means the chart can&#39;t be editable in word. &amp;nbsp;based on these two reason , we decide to implement one chart control of our own.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Technically, it is not difficult, but I do came across a few issues, and I resolve that.&amp;nbsp;&lt;/div&gt;&lt;div&gt;1. In GDI+ how to draw a text vertically.&amp;nbsp;&lt;/div&gt;&lt;div&gt;In GDI+ , the way to do it is rotate the axis, for example, if you want to rotate it 90 degree, then you can use RotateTransform function.&amp;nbsp;&lt;/div&gt;&lt;div&gt;Assume, you want to draw a text at point(100,100) vertically,here is how you gona to do that.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;e.Graphics.TranslateTransform(100,100);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;e.Graphics.RotateTransform(-90);&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;e.Graphics.DrawString(&quot;Hello&quot;, new Font(&quot;Arial&quot;, 10f, FontStyle.Regular), Brushes.Red, 0, 0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;e.Graphics.ResetTransform();&lt;/div&gt;&lt;div&gt;The reason why I mention this is , most post missed one point, that you need to translate your axis first, before you do the rotate. cause by default, rotate transform is roate the axis base on Point(0,0), if you don&#39;t translate your axis to the position where you want to draw your string, then most of the time, you will not be able to find the string you just drew, cause it is out of range.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2.In my case, the other challenge is how to draw on multiple platform(WPF, GDI+ and Word), I use an interface to abstract the underlying drawing functionality.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/8945297573135373084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/in-gdi-how-to-draw-text-vertically.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8945297573135373084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/8945297573135373084'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/in-gdi-how-to-draw-text-vertically.html' title='In GDI+ how to draw a text vertically.'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-1194296267082019059</id><published>2011-03-12T22:35:00.001-08:00</published><updated>2011-03-12T22:35:25.210-08:00</updated><title type='text'>How to setup Form Authentication Service through WCF</title><content type='html'>&lt;p&gt;These few days, I am trying to implement something based on my own interest. And I would like to host my business logic on my server. So Obviously WCF is a good choice.&amp;nbsp; but I was thinking how can I make sure that my service can be only accessed by legitimate users instead of everyone, then I thought of Form Authentication, and it turns out Microsoft already provide a solution for this. &lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb386582.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/bb386582.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Given the fact that there are already pretty much articles about this topic on internet, I just want to write what I had been through.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;When you invoke the authentication service, if you get an error message say that the service is disabled. Make sure that the following few lines exist in your web.config file, and enabled has been set to true.&lt;/li&gt; &lt;p&gt;&amp;lt;system.web.extensions&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;scripting&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;webServices&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;authenticationService enabled=&quot;true&quot;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; requireSSL = &quot;false&quot;/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/webServices&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp; &amp;lt;/scripting&amp;gt;&lt;br&gt; &amp;lt;/system.web.extensions&amp;gt;&lt;br&gt;&lt;/p&gt; &lt;li&gt;Why IsLoggedIn function always return false, even right after login.&amp;nbsp; &lt;/li&gt;&lt;/ol&gt; &lt;blockquote&gt; &lt;p&gt;Check your local config file, to make sure that allowCookies option had been turned on.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.&amp;nbsp; For all the service that protected by form authentication, when you call those services, make sure you had passed in the form cookie. otherwise , you will be kicked out.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/1194296267082019059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/how-to-setup-form-authentication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/1194296267082019059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/1194296267082019059'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/how-to-setup-form-authentication.html' title='How to setup Form Authentication Service through WCF'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-3449020473860394356</id><published>2011-03-07T04:08:00.000-08:00</published><updated>2011-03-07T04:08:15.923-08:00</updated><title type='text'>An interesting interview question, How to store an grid of which each dimension has more than 1m elements</title><content type='html'>One of my friend , he went to an interview, during the interview he was asked, if we have a grid , both x and y dimension have 1 million elements, &amp;nbsp;what kind of data structure you will use? Given the left top position of a view port , we also know the width and height of the view port, how we can quickly figure out those nodes in the viewport?&lt;br /&gt;&lt;br /&gt;I was thinking this these few days, assume each node in the grid, we need to persist it&#39;s x axis and y axis,&lt;br /&gt;public struct Node&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; int x;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; int y;&lt;br /&gt;}&lt;br /&gt;each node need at least 8 bytes in memory, put the memory alignment aside , don&#39;t worry about it at this moment, for an 1million * 1million grid, if we store all the nodes in memory, how big it will be,&lt;br /&gt;Total = &amp;nbsp;1million * 1million * 8 /1024/1024/1024 GB &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &amp;nbsp;7450.58GB&lt;br /&gt;so, obviously , it is not possible to store the whole grid in memory, we have to break down the grid to small grids.Assume the size of the view port is 1024 * 768, I will say each small grid, the size is 1024 * 768, a view port.&lt;br /&gt;&lt;br /&gt;Based on this , we can break down the big grid to a small one, I will call it page grid, but each cell in the grid, pointing to another grid, which is exactly the size of one view port, I call it a page, sorry, I borrow this idea from database .&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt;  &lt;td&gt;&lt;br /&gt;x:0-1024&lt;br /&gt;y:0-768&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:1024-2048&lt;br /&gt;y:0-768&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:2048-3072&lt;br /&gt;y:0-768&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:3072 - 4096&lt;br /&gt;y:0-768&lt;/td&gt; &lt;td&gt;&lt;br /&gt;......&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;x:0-1024&lt;br /&gt;y:768-1536&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:1024-2048&lt;br /&gt;y:768-1536&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:2048-3072&lt;br /&gt;y:768-1536&lt;/td&gt; &lt;td&gt;&lt;br /&gt;x:3072 - 4096&lt;br /&gt;y:768-1536&lt;/td&gt; &lt;td&gt;&lt;br /&gt;......&lt;/td&gt;  &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;....&lt;/td&gt; &lt;td&gt;&lt;br /&gt;....&lt;/td&gt; &lt;td&gt;&lt;br /&gt;....&lt;/td&gt; &lt;td&gt;&lt;br /&gt;....&lt;/td&gt; &lt;td&gt;&lt;br /&gt;......&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;The width of this new grid is 1million / 1024 = 977&lt;br /&gt;The height of this grid is 1million / 768 = 1303&lt;br /&gt;&lt;br /&gt;The data of each cell on above grid will be store on hard disk, based on the left top position of the view port, we can easily identify data in which cell we need to access. &amp;nbsp;the formula is quite simple&lt;br /&gt;maximum we will need to load in four cells of data. &amp;nbsp;think about it.&lt;br /&gt;&lt;br /&gt;In this way, the is not too big anymore, so we don&#39;t need to bother whether to use linked list or binary tree, &amp;nbsp;or whatever, &amp;nbsp;for linked list, it is not design for fast search, it is for easy expandable. while binary tree, it good for search, but maintenance cost is very high. obviously we need to balance&lt;br /&gt;&lt;br /&gt;while in this case , I will say , use an array or a hash map to persist the page grid, which is easy to search and maintain.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/3449020473860394356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/interesting-interview-question-how-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3449020473860394356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3449020473860394356'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/03/interesting-interview-question-how-to.html' title='An interesting interview question, How to store an grid of which each dimension has more than 1m elements'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-3938158018121943577</id><published>2011-02-27T21:47:00.000-08:00</published><updated>2011-02-27T21:47:36.761-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="DataGrid"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Highlight the column header and the first few cells in the DataGrid</title><content type='html'>In my application, I have a requirement, SelectionMode of the DataGrid has been set to Extend, and SelectionUnit is Cell, thus user can select each cell int the DataGrid, the first 4 or 5 columns in the data grid is used for display some information about the row, &amp;nbsp;so when user select a cell in the Grid, both the columnheader and the related information cell should be highlight , thus make it easier for user to understand what they are editing. like excel.&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://lh5.googleusercontent.com/-p1uoyh2s6QQ/TWs0wSmciqI/AAAAAAAAABE/ZgPszhr1B7U/s1600/test.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://lh5.googleusercontent.com/-p1uoyh2s6QQ/TWs0wSmciqI/AAAAAAAAABE/ZgPszhr1B7U/s1600/test.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Originally I was thinking to hook up a function with the CurrentCellChanged event, and then when the cell is changed, I manually to find the columns that need to be highlighted, and apply a style to it. but it is&amp;nbsp;ugly. so I am keep searching whether there is a better way to do that, finally I get it.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In terms of select the column header, &amp;nbsp;First of all, we should create a style and bind it to the column header, put the following xaml expression to your style, trigger part.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;&amp;lt;DataTrigger Value=&quot;True&quot;&amp;gt;&lt;br /&gt;                                &amp;lt;DataTrigger.Binding&amp;gt;&lt;br /&gt;                                    &amp;lt;MultiBinding Converter=&quot;{StaticResource IsHeaderCurrentConverter}&quot;&amp;gt;&lt;br /&gt;                                        &amp;lt;Binding RelativeSource=&quot;{RelativeSource Self}&quot; /&amp;gt;&lt;br /&gt;                                        &amp;lt;Binding Path=&quot;CurrentColumn&quot; RelativeSource=&quot;{RelativeSource FindAncestor,AncestorType={x:Type DataGrid}}&quot; /&amp;gt;&lt;br /&gt;                                    &amp;lt;/MultiBinding&amp;gt;&lt;br /&gt;&lt;br /&gt;                                &amp;lt;/DataTrigger.Binding&amp;gt;&lt;br /&gt;                                &amp;lt;Setter  TargetName=&quot;headerBorder&quot; Property=&quot;Background&quot;&lt;br /&gt;                                Value=&quot;Red&quot; /&amp;gt;&lt;br /&gt;                            &amp;lt;/DataTrigger&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;After that, create a convertor.&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;public class IsHeaderCurrentConverter : IMultiValueConverter&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;       &lt;br /&gt;        #region IMultiValueConverter Members&lt;br /&gt;&lt;br /&gt;        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)&lt;br /&gt;        {&lt;br /&gt;            bool bResult = false;&lt;br /&gt;            if (values[1] != null)&lt;br /&gt;            {&lt;br /&gt;                DataGridColumnHeader dgch = values[0] as DataGridColumnHeader;&lt;br /&gt;                System.Windows.Controls.DataGridTextColumn dgtc =&lt;br /&gt;                    values[1] as System.Windows.Controls.DataGridTextColumn;&lt;br /&gt;                if(dgtc.Header.ToString().CompareTo(dgch.Column.Header.ToString()) == 0)&lt;br /&gt;                {&lt;br /&gt;                    bResult = true;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return bResult;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)&lt;br /&gt;        {&lt;br /&gt;            throw new NotImplementedException();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the converter, if we return true, then the column header will be highlight with red.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Use the same theory , you can create a style to highlight the cells that you need to change when cell is selected.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/3938158018121943577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/highlight-column-header-and-first-few.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3938158018121943577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3938158018121943577'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/highlight-column-header-and-first-few.html' title='Highlight the column header and the first few cells in the DataGrid'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh5.googleusercontent.com/-p1uoyh2s6QQ/TWs0wSmciqI/AAAAAAAAABE/ZgPszhr1B7U/s72-c/test.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-7293269397857066704</id><published>2011-02-26T19:07:00.001-08:00</published><updated>2011-02-26T19:14:24.725-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>DataGrid, Create and load datatemplate on the fly.</title><content type='html'>&lt;p&gt;Recently , I was investigating how to port a winform application to use WPF.&amp;nbsp; the winform application is intensively using DataGrid. But it is using a lot of code to handle the style and appearance.&amp;nbsp; &lt;/p&gt; &lt;p&gt;In WPF, we have data binding which is very flexible. Here is what I learned recently. &lt;/p&gt; &lt;p&gt;1.How to bind columns on the fly using code behind.&lt;/p&gt; &lt;p&gt;Assume you have a model class, which can return you a DataTable object, while the columns in the DataTable varies by the input parameter which you passed in when you invoke the function.&amp;nbsp; The data in the table cell is a custom data type(SiteData),base on the DataType property of MyCellData object, we should use different style to differentiate it,Base on the column name we should decide hide or show the column,How to bind the DataTable to a DataGrid?&lt;/p&gt; &lt;p&gt;To be clear, I post a function to generated the data here, so based on the code, you know What I mean.&lt;/p&gt; &lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; DataTable ToDataTable()&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;            DataTable dt = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataTable();&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.CreateDummyData();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;            dt.Columns.Add(&lt;span class=&quot;str&quot;&gt;&quot;Row1&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(RowHeadInfo));&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;            dt.Columns.Add(&lt;span class=&quot;str&quot;&gt;&quot;Row2&quot;&lt;/span&gt;, &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(RowHeadInfo));&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (var i = 2000; i &amp;lt;= 2020; i++)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt; (var j = 0; j &amp;lt;= 4; j++)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;(j == 0)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;                        dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Y{0}&quot;&lt;/span&gt;, i, j), &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(SiteData));&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;                    &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;                        dt.Columns.Add(&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;.Format(&lt;span class=&quot;str&quot;&gt;&quot;Y{0}Q{1}&quot;&lt;/span&gt;, i, j), &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(SiteData));&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;                }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;foreach&lt;/span&gt; (var item &lt;span class=&quot;kwrd&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;._listRows)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;                item.ToDataTable(dt);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; dt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;        }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You might say just set the itemssource to the datatable, yeah, we should do that anyway, but it is not that easy, cause the data in the table is a custom data type, so you have to specify a binding to tell the grid which property to display, and we need trigger to change the style of display.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Eventually, we can’t write the DataGridColumns definition in xaml file. there are two solutions. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;a)You can use a loop to go through the columns in the DataTable and then use code to add column to the DataGrid.&amp;nbsp; use this method, you have to set the AutoGeneratedColumns to false.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;b)You can set the AutoGenerateColumn to true, while write a function to handle the AutoGeneratingColumn event. in this function , you can create and load data template use code.&lt;/p&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; dataGrid1_AutoGeneratingColumn(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, DataGridAutoGeneratingColumnEventArgs e)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (e.PropertyType == &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(RowHeadInfo))&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;                DataGridTextColumn dgtc = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataGridTextColumn();&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;                dgtc.IsReadOnly = &lt;span class=&quot;kwrd&quot;&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;                dgtc.Binding = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Binding(e.PropertyName + &lt;span class=&quot;str&quot;&gt;&quot;.RowName&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;                dgtc.CellStyle = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FindResource(&lt;span class=&quot;str&quot;&gt;&quot;RowHeaderSelectedStyle&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Style;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;                dgtc.HeaderStyle = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FindResource(&lt;span class=&quot;str&quot;&gt;&quot;NormalHeaderStyle&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Style;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                e.Column = dgtc;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (e.PropertyType == &lt;span class=&quot;kwrd&quot;&gt;typeof&lt;/span&gt;(SiteData))&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;                DataGridTextColumn dgtc = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataGridTextColumn();&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;                dgtc.Width = 50;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;                dgtc.Binding = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; Binding(e.PropertyName)&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;                {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;                    &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;                    Converter = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; DataCellConverter(),&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;                    Mode = BindingMode.TwoWay&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;                };&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;                &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (e.PropertyName.Contains(&lt;span class=&quot;str&quot;&gt;&quot;Q&quot;&lt;/span&gt;))&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;                {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;                    dgtc.Visibility = Visibility.Hidden;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;                    dgtc.HeaderStyle = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FindResource(&lt;span class=&quot;str&quot;&gt;&quot;NormalHeaderStyle&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Style;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  27:  &lt;/span&gt;                }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  28:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  29:  &lt;/span&gt;                {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  30:  &lt;/span&gt;                    dgtc.HeaderStyle = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.FindResource(&lt;span class=&quot;str&quot;&gt;&quot;NormalHeaderStyleWithCheckBox&quot;&lt;/span&gt;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Style;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  31:  &lt;/span&gt;                }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  32:  &lt;/span&gt;                &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  33:  &lt;/span&gt;                dgtc.CanUserSort = &lt;span class=&quot;kwrd&quot;&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  34:  &lt;/span&gt;                dgtc.Header = e.PropertyName;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  35:  &lt;/span&gt;                &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  36:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; strStyle = Properties.Resources.NormalDataCellStyle;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  37:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; strValue = strStyle.Replace(&lt;span class=&quot;str&quot;&gt;&quot;{0}&quot;&lt;/span&gt;, e.PropertyName);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  38:  &lt;/span&gt;                XmlReader xr = XmlReader.Create(&lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; StringReader(strValue));&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  39:  &lt;/span&gt;                Style st = (Style)XamlReader.Load(xr);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  40:  &lt;/span&gt;                dgtc.CellStyle = st;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  41:  &lt;/span&gt;                e.Column = dgtc;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  42:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  43:  &lt;/span&gt;        }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&amp;lt;Style  TargetType=&lt;span class=&quot;str&quot;&gt;&quot;{x:Type DataGridCell}&quot;&lt;/span&gt;  xmlns=&lt;span class=&quot;str&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/span&gt; xmlns:x=&lt;span class=&quot;str&quot;&gt;&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;            &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;Background&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Green&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;            &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;Foreground&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;White&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;            &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;HorizontalAlignment&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Stretch&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;            &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;VerticalAlignment&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Center&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;            &amp;lt;Style.Triggers&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;                &amp;lt;DataTrigger Binding=&lt;span class=&quot;str&quot;&gt;&quot;{Binding Path={0}.SiteDataType}&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;                    &amp;lt;DataTrigger.Value&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;                        REPORT&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                    &amp;lt;/DataTrigger.Value&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;                    &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;Background&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Red&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;                &amp;lt;/DataTrigger&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;                &amp;lt;DataTrigger Binding=&lt;span class=&quot;str&quot;&gt;&quot;{Binding Path={0}.SiteDataType}&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;                    &amp;lt;DataTrigger.Value&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;                        ESTIMATE&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;                    &amp;lt;/DataTrigger.Value&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;                    &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;Background&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Yellow&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;                &amp;lt;/DataTrigger&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;                &amp;lt;Trigger Property=&lt;span class=&quot;str&quot;&gt;&quot;IsSelected&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;True&quot;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;                    &amp;lt;Setter Property=&lt;span class=&quot;str&quot;&gt;&quot;Background&quot;&lt;/span&gt; Value=&lt;span class=&quot;str&quot;&gt;&quot;Green&quot;&lt;/span&gt; /&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;                &amp;lt;/Trigger&amp;gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;            &amp;lt;/Style.Triggers&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;        &amp;lt;/Style&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, &quot;Courier New&quot;, courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;  </content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/7293269397857066704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/datagrid-create-and-load-datatemplate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7293269397857066704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7293269397857066704'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/datagrid-create-and-load-datatemplate.html' title='DataGrid, Create and load datatemplate on the fly.'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-3303014689149463229</id><published>2011-02-11T05:29:00.000-08:00</published><updated>2011-02-11T05:29:39.307-08:00</updated><title type='text'>How to do DB load test</title><content type='html'>For a portal which with very high traffic, Database is the one the will directly affect the performance of your website, so every time, when you need to deploy some store procedure or database changes, you will always think that whether you stuff will greatly affect the sites.&amp;nbsp;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Recently In order to reproduce one db issue we came across, we are trying to reproduce it on our dev environment. but after quite a lot try, we don&#39;t have any luck. so we are thinking whether we can do some load test on our database. &amp;nbsp;fortunately , with VS2008 we can actually do that easily. You might ask ,a lot people are already on VS2010, but unfortunately , this feature had been turned off in VS2010, but it still there, if you want to use it , you have to buy it... so you know why Microsoft is rich...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I had done some search via internet, but didn&#39;t find too much articles introducing how to do it, so I write this post, hopefully it will help someone later on, knowledge should be shared.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1 , you should use your VS2008 to create a test project, it is easy&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-lKkQIf2GwzE/TVU06E4MabI/AAAAAAAAAAg/MhTlKQM5k9c/s1600/step1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;http://4.bp.blogspot.com/-lKkQIf2GwzE/TVU06E4MabI/AAAAAAAAAAg/MhTlKQM5k9c/s320/step1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 2,In the solution explorer, right click your project name , on the coming out context menu, click add a unit test, then select database unit test, refer to the following snapshot.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-L_dJjxbMdrA/TVU1qBojJHI/AAAAAAAAAAk/J0x6soUnRfg/s1600/step2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;264&quot; src=&quot;http://4.bp.blogspot.com/-L_dJjxbMdrA/TVU1qBojJHI/AAAAAAAAAAk/J0x6soUnRfg/s320/step2.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 3, in the coming out dialog, it will ask you to select a database, if your database connection is already there, you can just select one, or create a new one.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-EMyKtVuO8yI/TVU2M-fVxJI/AAAAAAAAAAo/k1R-HvCzcwM/s1600/step3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://1.bp.blogspot.com/-EMyKtVuO8yI/TVU2M-fVxJI/AAAAAAAAAAo/k1R-HvCzcwM/s320/step3.png&quot; width=&quot;257&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;step4, create the test, on the following snapshot reflect screen, you can just click the &quot;click here to create&quot; link to create a database unit test case. basically once you hit the link , it will go to code mode, and allow you to type in a SQL statement, which you used for test.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&amp;nbsp;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-lE81A3jstYQ/TVU3SajSLqI/AAAAAAAAAAw/KOT6XynKzQI/s1600/step4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;http://4.bp.blogspot.com/-lE81A3jstYQ/TVU3SajSLqI/AAAAAAAAAAw/KOT6XynKzQI/s320/step4.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;Code window&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-CbbsDhRVQig/TVU3nVeIUxI/AAAAAAAAAA0/3ARXOVh_uFQ/s1600/step5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;182&quot; src=&quot;http://1.bp.blogspot.com/-CbbsDhRVQig/TVU3nVeIUxI/AAAAAAAAAA0/3ARXOVh_uFQ/s320/step5.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 5, add a load test, in your test project , go to solution explorer, and right click your project, on the coming out context menu&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-mULJORp3ZEk/TVU4TeawVHI/AAAAAAAAAA8/KreHGAmE9dU/s1600/step6.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;316&quot; src=&quot;http://4.bp.blogspot.com/-mULJORp3ZEk/TVU4TeawVHI/AAAAAAAAAA8/KreHGAmE9dU/s320/step6.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Follow the load test wizard, usually, for Database test, we select step load, which means we will increase user load&amp;nbsp;steady until it reach the maximum.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;In the test mix, you can select the database test , which you just created.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-qyWfio1aPWY/TVU5T71bYVI/AAAAAAAAABA/3ny-nbelRmw/s1600/selecttest.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;242&quot; src=&quot;http://1.bp.blogspot.com/-qyWfio1aPWY/TVU5T71bYVI/AAAAAAAAABA/3ny-nbelRmw/s320/selecttest.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Then your database load test is ready. run it , and check the performance counters....&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/3303014689149463229/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/how-to-do-db-load-test.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3303014689149463229'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/3303014689149463229'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/how-to-do-db-load-test.html' title='How to do DB load test'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-lKkQIf2GwzE/TVU06E4MabI/AAAAAAAAAAg/MhTlKQM5k9c/s72-c/step1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-2511503064814967037</id><published>2011-02-10T04:25:00.000-08:00</published><updated>2011-02-10T04:25:21.993-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight"/><title type='text'>How to play steam video in Silverlight 4.0</title><content type='html'>Today , I am investigating how to play video in Silverlight 4.0 , &amp;nbsp;using MediaElement, it is quite easy to play a video in local disk , or hold in a server that can be accessed through http. &amp;nbsp;but unfortunately , our server is in a seperate server, and exposed as mms stream. &amp;nbsp;&lt;br /&gt;&lt;br /&gt;it is quite headache , I was plan to use telerik&#39;s media play control, but it can&#39;t support mms stream as well. it takes me a few hours to look around, but no luck , finally I was thinking whether I can change the mms protocol to using http to see what will happen, &amp;nbsp;the interesting thing is , I change the mms to http at the video url, and paste to chrome, and I found I can access it and play it successfully in a browser.&lt;br /&gt;&lt;br /&gt;so I use MediaElement, and change the video url protocol to http and set to the source property of MediaElement, it works smoothly....&lt;br /&gt;&lt;br /&gt;Is that mean mms is based on http? need to figure this out.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/2511503064814967037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/how-to-play-steam-video-in-silverlight.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2511503064814967037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/2511503064814967037'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/how-to-play-steam-video-in-silverlight.html' title='How to play steam video in Silverlight 4.0'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-4861726049630642361</id><published>2011-02-08T01:58:00.000-08:00</published><updated>2011-02-08T01:58:01.436-08:00</updated><title type='text'>Silverlight 4.0 drag and drop -- continue</title><content type='html'>In a previous post, I mentioned the drag and drop in Silverlight 4, cause we upgrade to SL 4 recently, we were using the Silverlight Toolkit, ListBoxDragDropTarget, but in Silverlight 4, the performance of drag and drop control is deteriorative , even the issue that sometimes it lost mouse key up can be fixed, but still can&#39;t meet user&#39;s expectation.&lt;br /&gt;&lt;br /&gt;So these few days, I tried to use telerik&#39;s silverlight controls, basically the performance is much better, and user experience is much better. &amp;nbsp;drag and drop much more smooth than silverlight toolkit, of course it will be better cause you gonna to pay it.&lt;br /&gt;&lt;br /&gt;To be honest the silverlight toolkit drag and drop is quite automatic, you don&#39;t need to write too much code to make the drag and drop to work. &amp;nbsp;in this way, you also don&#39;t have too much control over it. while the drag and drop control of telerik on the contract , it gives you more control and require you to implement more logic and code to make it work.&lt;br /&gt;&lt;br /&gt;Secondly, toolkit drag and drop can show some very good indicator when you drag over your drop target. such as insert indicator, etc.. while telerik control doesn&#39;t have that.&lt;br /&gt;&lt;br /&gt;BTW. before I move to third party controls, I also looked into the toolkit source code, and find there are intensively use LINQ , which complex the who logic, and finally make me give up fixing the issues.&lt;br /&gt;&lt;br /&gt;Just for the reference of those who also come across the same issue and considering some third party controls.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/4861726049630642361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/silverlight-40-drag-and-drop-continue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/4861726049630642361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/4861726049630642361'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/silverlight-40-drag-and-drop-continue.html' title='Silverlight 4.0 drag and drop -- continue'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-5999775962192854190</id><published>2011-02-07T02:53:00.000-08:00</published><updated>2011-02-07T02:54:31.827-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2005"/><title type='text'>avoid checking parameters at where clause.</title><content type='html'>Recently , we came across an issue, when massive traffic come in, one of our store procedure will trigger very very high CPU usage, &amp;nbsp;at some point, it trigger the CPU usage spike to 90% percent, which greatly increase the database response time, and our service is timing out, also it slow down the other websites which are also connecting this database. &amp;nbsp;In our dev environment , when we look at the store procedure, it looks totally fine, we check the execution plan, it is good as well, we are using index seek , nothing is expensive at all.&lt;br /&gt;Today we create a load test using Visual Studio 2010, which can simulate 1000 or 2000 concurrent online user and be able to reproduce the issue, and we have an interesting finding.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;We are doing parameter check at where clause.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;assume In SQL Server, if you have store procedure, which can pass in an @UserID INT, when @UserID is 0, you would like to skip this parameter, only use it when @UserID is not zero. &amp;nbsp;so the SQL Statement you can write like this.&lt;br /&gt;&lt;br /&gt;SELECT ID,REALNAME,USERNAME FROM USERS where (@UserID=0 OR ID=@UserID)&lt;br /&gt;&lt;br /&gt;When you looked at this statement it is fine, and when you try it , it works as well but it is problematic.&lt;br /&gt;a)When you have a lot of traffic on a store procedure that is implemented in this way, you will find this statement use far more CPU resource than others. &amp;nbsp;in our case, the store procedure cause the SQL Server CPU to spike , and it reach 90% , and keep high. &amp;nbsp;after we take this statement out, CPU usage goes down to around 50 percent.&lt;br /&gt;b)if you write SQL Statement this way, SQL Server will not be able to pick up appropriate index.&lt;br /&gt;&lt;br /&gt;So be careful, if you are writing some SQL statement which will be executed on a database with high traffic, please avoid it.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/5999775962192854190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/avoid-sql-server-check-parameters-at.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5999775962192854190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5999775962192854190'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/avoid-sql-server-check-parameters-at.html' title='avoid checking parameters at where clause.'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-5640015666554132892</id><published>2011-02-04T19:56:00.000-08:00</published><updated>2011-02-04T19:56:29.384-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><title type='text'>Caculate how many one in a bit format of int value</title><content type='html'>Everyone knows that in computer, no matter what type you are using, finally it will be represent with bits , 0 and 1 . &amp;nbsp; For example&lt;br /&gt;INT value &amp;nbsp; &amp;nbsp;Bit&lt;br /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0001&lt;br /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0010&lt;br /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0011&lt;br /&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0100&lt;br /&gt;and so on....&lt;br /&gt;&lt;br /&gt;A couple days ago, I was asked, given an int value, can you print out it in bit format, and caculate how many 1 in the bit level.&lt;br /&gt;&lt;br /&gt;First of all, it is quite easy to get the bit string of the int value, just use convert function.&lt;br /&gt;Secondly , caculate how many one in the bit string, you can use &amp;amp; operator and &amp;gt;&amp;gt; operator&lt;br /&gt;&lt;br /&gt;&lt;style type=&quot;text/css&quot;&gt;.csharpcode, .csharpcode pre {  font-size: small;  color: black;  font-family: Consolas, &quot;Courier New&quot;, Courier, Monospace;  background-color: #ffffff;  /*white-space: pre;*/ }  .csharpcode pre { margin: 0em; }  .csharpcode .rem { color: #008000; }  .csharpcode .kwrd { color: #0000ff; }  .csharpcode .str { color: #006080; }  .csharpcode .op { color: #0000c0; }  .csharpcode .preproc { color: #cc6633; }  .csharpcode .asp { background-color: #ffff00; }  .csharpcode .html { color: #800000; }  .csharpcode .attr { color: #ff0000; }  .csharpcode .alt  {  background-color: #f4f4f4;  width: 100%;  margin: 0em; }  .csharpcode .lnum { color: #606060; } &lt;/style&gt;&lt;br /&gt;&lt;div class=&quot;csharpcode&quot;&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   1:  &lt;/span&gt;&lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MainClass&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   2:  &lt;/span&gt;    {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   3:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;readonly&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; LENOFBIT = 8;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   4:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; Main (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   5:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   6:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; iValueToTest = 12345;&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   7:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; strBit = Convert.ToString(iValueToTest,2);&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;   8:  &lt;/span&gt;            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;int value {0} in bit format is {1}&quot;&lt;/span&gt;,iValueToTest,strBit);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;   9:  &lt;/span&gt;            Console.WriteLine(&lt;span class=&quot;str&quot;&gt;&quot;there are {0} one in bit format&quot;&lt;/span&gt;,CaculateOne(iValueToTest));&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  10:  &lt;/span&gt;                        &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  11:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  12:  &lt;/span&gt;        &lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  13:  &lt;/span&gt;        &lt;span class=&quot;kwrd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; CaculateOne(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; iValue)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  14:  &lt;/span&gt;        {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  15:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; iResult = 0;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  16:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; iLen = &lt;span class=&quot;kwrd&quot;&gt;sizeof&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  17:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;kwrd&quot;&gt;int&lt;/span&gt; i=0;i&amp;lt;iLen * LENOFBIT;i++)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  18:  &lt;/span&gt;            {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  19:  &lt;/span&gt;                &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt;((iValue &amp;amp; 1) == 1)&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  20:  &lt;/span&gt;                {&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  21:  &lt;/span&gt;                    iResult ++;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  22:  &lt;/span&gt;                }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  23:  &lt;/span&gt;                iValue = iValue &amp;gt;&amp;gt; 1;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  24:  &lt;/span&gt;            }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  25:  &lt;/span&gt;            &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; iResult;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  26:  &lt;/span&gt;        }&lt;/pre&gt;&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;  27:  &lt;/span&gt;        &lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;lnum&quot;&gt;  28:  &lt;/span&gt;    }&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;You may ask , what the hell this is used for? assume you are implementing a user permission system, &amp;nbsp;you can use each bit to represent a permission, thus an int value can represent 32 permissions.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/5640015666554132892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/caculate-how-many-one-in-bit-format-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5640015666554132892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5640015666554132892'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/02/caculate-how-many-one-in-bit-format-of.html' title='Caculate how many one in a bit format of int value'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-7808225522561398985</id><published>2011-01-28T21:22:00.000-08:00</published><updated>2011-01-28T21:36:22.443-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linked list"/><title type='text'>How to detect a loop in a single linked list</title><content type='html'>Continue my topic regarding linked list, I couple days ago , after I create the linked list class, I was thinking , in a single list, if one node point to a node prior to itself in the list, then it create a loop. &amp;nbsp;Then when you traverse the linked list, Ooops! you get into a dead loop. &lt;br /&gt;So I was thinking How to detect this loop situation, then I did some research over internet, I do find quite a lot good articles. &amp;nbsp;here is one, &amp;nbsp;&lt;a href=&quot;http://ostermiller.org/find_loop_singly_linked_list.html&quot;&gt;http://ostermiller.org/find_loop_singly_linked_list.html&lt;/a&gt;&amp;nbsp;it explain good solutions and bad solutions.&lt;br /&gt;this is another one explain how to address the culprit which cause the loop&amp;nbsp;&lt;a href=&quot;http://crackinterviewtoday.wordpress.com/2010/03/16/calculate-node-that-causes-loop-in-a-linked-list/&quot;&gt;http://crackinterviewtoday.wordpress.com/2010/03/16/calculate-node-that-causes-loop-in-a-linked-list/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Today,I get some time , so I implement the function , here is the code.&lt;br /&gt;Not only this function can address the loop, but also , it can address the exact node that cause it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;public bool hasLoop()&lt;br /&gt;        {&lt;br /&gt;            bool bReturn = false;&lt;br /&gt;            &lt;br /&gt;            if(_root != null &amp;amp;&amp;amp; _root.next != null)&lt;br /&gt;            {&lt;br /&gt;                Node slow = _root;&lt;br /&gt;                Node fast1 = Root;&lt;br /&gt;                Node fast2 = Root;&lt;br /&gt;                while(slow != null)&lt;br /&gt;                {&lt;br /&gt;                    fast1 = fast2.next;&lt;br /&gt;                    if(fast1 != null)&lt;br /&gt;                    {&lt;br /&gt;                        fast2 = fast1.next;&lt;br /&gt;                        if(fast1 == slow || fast2 == slow) //we have a loop&lt;br /&gt;                        {&lt;br /&gt;                            bReturn = true;&lt;br /&gt;                            break;&lt;br /&gt;                        }&lt;br /&gt;                        else if(fast2 == null)//fast2 reach the end of linked list.&lt;br /&gt;                        {&lt;br /&gt;                            break;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                    else //fast1 is null means we reach the end of the linked list.&lt;br /&gt;                    { &lt;br /&gt;                        break;&lt;br /&gt;                    }&lt;br /&gt;                    slow = slow.next;&lt;br /&gt;                }&lt;br /&gt;                slow = slow.next;&lt;br /&gt;                Console.WriteLine(string.Format(&quot;Node:{0} cause a loop...&quot;,slow.Name));&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            return bReturn;&lt;br /&gt;        }&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/7808225522561398985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/how-to-detect-loop-in-single-linked.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7808225522561398985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7808225522561398985'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/how-to-detect-loop-in-single-linked.html' title='How to detect a loop in a single linked list'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-7645315741837836807</id><published>2011-01-28T19:32:00.000-08:00</published><updated>2011-01-28T19:32:29.452-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight"/><title type='text'>Silverlight drag and drop issue</title><content type='html'>This week , I upgrade our project to silverlight 4, you know silverlight 4 is on the market for a long time, but&amp;nbsp;unfortunately&amp;nbsp;, we are still using silverlight 3.0, constrained by the infrastructure. cause it is not easy to change our build server. &amp;nbsp;finally now it is silverlight 4.&lt;br /&gt;&lt;br /&gt;Once I finish up the upgrade, I came across a drag and drop issue. In silverlight 4, when I move mouse on the top of a ListBoxDragDropTarget, even me mouse left key is not down, but sometimes, it just start to drag....Which might cause a lot problem. &amp;nbsp;after some search , it turns out it is a bug of silverlight 4 toolkit, and I found a solution here &amp;nbsp;&lt;a href=&quot;http://silverlight.codeplex.com/workitem/5930&quot;&gt;http://silverlight.codeplex.com/workitem/5930&lt;/a&gt;&amp;nbsp;, this solution works for me.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/7645315741837836807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/silverlight-drag-and-drop-issue.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7645315741837836807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/7645315741837836807'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/silverlight-drag-and-drop-issue.html' title='Silverlight drag and drop issue'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4422419057570353749.post-5094629783908849770</id><published>2011-01-25T21:45:00.000-08:00</published><updated>2011-01-25T21:45:29.781-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linked list"/><title type='text'>How to reverse a linked list</title><content type='html'>If you go for an interview and the position which you are interviewing for is r&amp;amp;d focus, then most likely they will ask you some very basic technologies,data structures. &amp;nbsp;Which you might learned from your uni, but after so many years of working, you almost forget about it.&lt;br /&gt;&lt;br /&gt;Recently I came across a question: how to reverse a linked list?&lt;br /&gt;&lt;br /&gt;Linked list is quite easy , &amp;nbsp;if you don&#39;t know about it , you can go to&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Linked_list&quot;&gt;http://en.wikipedia.org/wiki/Linked_list&lt;/a&gt;&amp;nbsp;to read more.&lt;br /&gt;&lt;br /&gt;From the question you can know , that the linked list which require you to reverse is single linked list. &amp;nbsp;cause double linked list, there is no point to reverse.&lt;br /&gt;&lt;br /&gt;They give me a marker , and ask me to write down the function on a white board. I spend around 10 minutes and didn&#39;t get it right, then they lost patience. &amp;nbsp; the problem for me , is &amp;nbsp;I am not used to write any code on a board....&lt;br /&gt;&lt;br /&gt;So today I create a function to reverse a linked list. Include build the linked list, traverse , and reverse , it totally take me around half an hour in front of my PC.&lt;br /&gt;&lt;br /&gt;First of all , we need to define a class which can be used to represent a linked list.&lt;br /&gt;&lt;br /&gt;internal class Node&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public Node(string strName)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;this._name = strName;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;private string _name = string.Empty;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public string Name&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;get{return this._name;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;set{this.Name = value;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;private Node _next = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public Node next&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;get{return this._next;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;set{this._next = value;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void setNext(Node node)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;this.next = node;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;internal class LinkedList&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public string[] arrList = {&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;D&quot;,&quot;E&quot;,&quot;F&quot;,&quot;G&quot;,&quot;H&quot;,&quot;I&quot;,&quot;J&quot;,&quot;K&quot;,&quot;L&quot;,&quot;M&quot;,&quot;N&quot;,&quot;O&quot;,&quot;P&quot;,&quot;Q&quot;,&quot;R&quot;,&quot;S&quot;,&quot;T&quot;,&quot;U&quot;,&quot;V&quot;,&quot;W&quot;,&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;};&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;private Node _root = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public LinkedList ()&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;//build the link list&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;_root = new Node(arrList[0]);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Node indicator = _root;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(int i=1;i&amp;lt;arrList.Length;i++)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Node tmp = new Node(arrList[i]);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;indicator.setNext(tmp);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;indicator = tmp;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public Node Root&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;get&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;return _root;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void Traverse(Node root)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(root != null)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;while(root.next != null)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;Console.Write(&quot;{0},&quot;,root.Name);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;root = root.next;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Console.WriteLine(&quot;{0}&quot;,root.Name);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//This the&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void Reverse()&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Node indicator = _root;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Node temp = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;while(indicator.next != null)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Node temp1 = indicator.next;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;indicator.next = temp;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;temp = indicator;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;indicator = temp1;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;indicator.next = temp;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;_root = indicator;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;There are also some interesting questions regarding linked list. for example:&lt;br /&gt;1.How you can determinate whether there is a loop in your linked list?&lt;br /&gt;2.How to find out the node which cause loop?&lt;br /&gt;&lt;br /&gt;I will post the functions later.</content><link rel='replies' type='application/atom+xml' href='http://johnnystechnicallife.blogspot.com/feeds/5094629783908849770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/how-to-reverse-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5094629783908849770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4422419057570353749/posts/default/5094629783908849770'/><link rel='alternate' type='text/html' href='http://johnnystechnicallife.blogspot.com/2011/01/how-to-reverse-linked-list.html' title='How to reverse a linked list'/><author><name>Johnny Luo</name><uri>https://plus.google.com/109868668236995834566</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-NYPFOL0XQUY/AAAAAAAAAAI/AAAAAAAACx4/xrebQwc9uyc/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>