Burrowhttp://www.nhforge.org/wikis/burrow/default.aspxLight weight middleware developed to support .Net applications using NHibernateen-USCommunityServer 2008.5 Beta (Build: 30821.2512)Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/7.aspxSun, 07 Sep 2008 20:01:06 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:99kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<h4><b>Why Is Burrow Needed?</b></h4> <p>Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br />Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br />The core concept of Burrow is <a class="ExistingPageLink" href="/wikis/burrow/conversation-explained.aspx" title="Click to view the page titled: Burrow Conversation">Burrow Conversation</a>, which was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br />For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br />OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br />For more information about Burrow Conversation, <a class="ExistingPageLink" href="/wikis/burrow/conversation-explained.aspx" title="Click to view the page titled: Burrow Conversation">click here</a>. </p> <h4>Main Features of Burrow</h4> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases. </li> </ul> <h4><b>A Simple Example about Long Conversation</b></h4> <p>To demonstrate Burrow, we used the basic example from the well-known article &quot;<a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it: </p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore </li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock </li> </ul> <p><br />Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /><b>PlaceOrder.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:368px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;true&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Select a customer who wants to place an order (will be the OrderBy)<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:DropDownList</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;ddlCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DataTextField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">DataValueField</span><span style="color:#0000ff;">=&quot;ID&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:DropDownList</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Step1&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phEnterShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Please enter your ship to information:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;tbShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:TextBox</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnEnterShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnStep2&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;cancel&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Button</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span>Customer:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Ship to:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Confirm&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Finish&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br /><b>PlaceOrder.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:923px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> PlaceOrder : Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">private</span> IDaoFactory daoFactory = <span style="color:#0000ff;">new</span> NHibernateDaoFactory();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#008000;">/// &lt;summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#008000;">/// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#008000;">/// &lt;/summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">public</span> Order placingOrder {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> get { <span style="color:#0000ff;">return</span> (Order) bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>]; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> set { bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>] = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Page_Load(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> <span style="color:#0000ff;">if</span> (!IsPostBack) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span> ddlCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Step1(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> <span style="color:#008000;">//start an atomic Conversation that span over postbacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, <span style="color:#0000ff;">false</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> placingOrder = <span style="color:#0000ff;">new</span> Order(selectedCustomer) ;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnStep2(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> placingOrder.ShipToName = tbShipToName.Text;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> phConfirm.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> lCustomer.Text = placingOrder.OrderedBy.ToString();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span> lShipTo.Text = placingOrder.ShipToName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Cancel(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// give up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> StartOver() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Finish(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> placingOrder.OrderDate = DateTime.Now;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> daoFactory.GetOrderDao().Save(placingOrder);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> bf.CurrentConversation.FinishSpan(); <span style="color:#008000;">//finish up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> placingOrder = <span style="color:#0000ff;">null</span>; <span style="color:#008000;">//reset the placing order to null after conversation is done is a good practice</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> phConfirm.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 53:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 54:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 55:</span> }</pre> </div> </div> <pre> </pre> <p><br />In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br />For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/6.aspxSun, 07 Sep 2008 20:00:06 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:81kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<h4><b>Why Is Burrow Needed?</b></h4> <p>Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br />Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br />The core concept of Burrow is <a class="ExistingPageLink" href="/wikis/burrow/conversation-explained.aspx" title="Click to view the page titled: Burrow Conversation">Burrow Conversation</a>, which was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br />For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br />OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br />For more information about Burrow Conversation, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">click here</a>. </p> <h4>Main Features of Burrow</h4> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases. </li> </ul> <h4><b>A Simple Example about Long Conversation</b></h4> <p>To demonstrate Burrow, we used the basic example from the well-known article &quot;<a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it: </p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore </li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock </li> </ul> <p><br />Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /><b>PlaceOrder.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:368px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;true&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Select a customer who wants to place an order (will be the OrderBy)<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:DropDownList</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;ddlCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DataTextField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">DataValueField</span><span style="color:#0000ff;">=&quot;ID&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:DropDownList</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Step1&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phEnterShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Please enter your ship to information:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;tbShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:TextBox</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnEnterShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnStep2&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;cancel&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Button</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span>Customer:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Ship to:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Confirm&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Finish&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br /><b>PlaceOrder.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:923px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> PlaceOrder : Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">private</span> IDaoFactory daoFactory = <span style="color:#0000ff;">new</span> NHibernateDaoFactory();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#008000;">/// &lt;summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#008000;">/// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#008000;">/// &lt;/summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">public</span> Order placingOrder {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> get { <span style="color:#0000ff;">return</span> (Order) bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>]; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> set { bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>] = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Page_Load(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> <span style="color:#0000ff;">if</span> (!IsPostBack) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span> ddlCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Step1(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> <span style="color:#008000;">//start an atomic Conversation that span over postbacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, <span style="color:#0000ff;">false</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> placingOrder = <span style="color:#0000ff;">new</span> Order(selectedCustomer) ;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnStep2(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> placingOrder.ShipToName = tbShipToName.Text;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> phConfirm.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> lCustomer.Text = placingOrder.OrderedBy.ToString();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span> lShipTo.Text = placingOrder.ShipToName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Cancel(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// give up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> StartOver() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Finish(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> placingOrder.OrderDate = DateTime.Now;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> daoFactory.GetOrderDao().Save(placingOrder);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> bf.CurrentConversation.FinishSpan(); <span style="color:#008000;">//finish up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> placingOrder = <span style="color:#0000ff;">null</span>; <span style="color:#008000;">//reset the placing order to null after conversation is done is a good practice</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> phConfirm.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 53:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 54:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 55:</span> }</pre> </div> </div> <pre> </pre> <p><br />In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br />For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/5.aspxSun, 07 Sep 2008 18:06:35 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:80kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<h4><b>Why Is Burrow Needed?</b></h4> <p>Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br />Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br />The core concept of Burrow is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br />For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br />OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br />For more information about Burrow Conversation, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">click here</a>. </p> <h4>Main Features of Burrow</h4> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases. </li> </ul> <h4><b>A Simple Example about Long Conversation</b></h4> <p>To demonstrate Burrow, we used the basic example from the well-known article &quot;<a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it: </p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore </li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock </li> </ul> <p><br />Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /><b>PlaceOrder.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:368px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;true&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Select a customer who wants to place an order (will be the OrderBy)<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:DropDownList</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;ddlCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DataTextField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">DataValueField</span><span style="color:#0000ff;">=&quot;ID&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:DropDownList</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Step1&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phEnterShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Please enter your ship to information:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;tbShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:TextBox</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnEnterShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnStep2&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;cancel&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Button</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span>Customer:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Ship to:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Confirm&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Finish&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br /><b>PlaceOrder.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:923px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> PlaceOrder : Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">private</span> IDaoFactory daoFactory = <span style="color:#0000ff;">new</span> NHibernateDaoFactory();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#008000;">/// &lt;summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#008000;">/// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#008000;">/// &lt;/summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">public</span> Order placingOrder {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> get { <span style="color:#0000ff;">return</span> (Order) bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>]; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> set { bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>] = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Page_Load(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> <span style="color:#0000ff;">if</span> (!IsPostBack) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span> ddlCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Step1(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> <span style="color:#008000;">//start an atomic Conversation that span over postbacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, <span style="color:#0000ff;">false</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> placingOrder = <span style="color:#0000ff;">new</span> Order(selectedCustomer) ;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnStep2(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> placingOrder.ShipToName = tbShipToName.Text;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> phConfirm.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> lCustomer.Text = placingOrder.OrderedBy.ToString();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span> lShipTo.Text = placingOrder.ShipToName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Cancel(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// give up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> StartOver() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Finish(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> placingOrder.OrderDate = DateTime.Now;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> daoFactory.GetOrderDao().Save(placingOrder);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> bf.CurrentConversation.FinishSpan(); <span style="color:#008000;">//finish up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> placingOrder = <span style="color:#0000ff;">null</span>; <span style="color:#008000;">//reset the placing order to null after conversation is done is a good practice</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> phConfirm.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 53:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 54:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 55:</span> }</pre> </div> </div> <pre> </pre> <p><br />In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br />For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/4.aspxSun, 07 Sep 2008 18:05:15 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:64kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<h4><b>Why Is Burrow Needed?</b></h4> <p>Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br />Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br />The core concept of Burrow is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br />For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br />OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br />For more information about Burrow Conversation, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">click here</a>. </p> <h4>Main Features of Burrow</h4> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases. </li> </ul> <h4><b>A Simple Example about Long Conversation</b></h4> <p>To demonstrate Burrow, we used the basic example from the well-known article &quot;<a href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it: </p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore </li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock </li> </ul> <p><br />Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /><b>PlaceOrder.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:368px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;true&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Select a customer who wants to place an order (will be the OrderBy)<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:DropDownList</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;ddlCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DataTextField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">DataValueField</span><span style="color:#0000ff;">=&quot;ID&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:DropDownList</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnSelectCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Step1&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phEnterShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Please enter your ship to information:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;tbShipToName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:TextBox</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnEnterShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Next&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnStep2&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;cancel&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Button</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:PlaceHolder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;phConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span>Customer:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lCustomer&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> Ship to:</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Literal</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lShipTo&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;&lt;/</span><span style="color:#800000;">asp:Literal</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnConfirm&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Confirm&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;Finish&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:PlaceHolder</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br /><b>PlaceOrder.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> PlaceOrder : Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">private</span> IDaoFactory daoFactory = <span style="color:#0000ff;">new</span> NHibernateDaoFactory();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#008000;">/// &lt;summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#008000;">/// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#008000;">/// &lt;/summary&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">public</span> Order placingOrder {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> get { <span style="color:#0000ff;">return</span> (Order) bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>]; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> set { bf.CurrentConversation.Items[<span style="color:#006080;">&quot;placingOrder&quot;</span>] = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Page_Load(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> <span style="color:#0000ff;">if</span> (!IsPostBack) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span> ddlCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Step1(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> <span style="color:#008000;">//start an atomic Conversation that span over postbacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, <span style="color:#0000ff;">false</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> placingOrder = <span style="color:#0000ff;">new</span> Order(selectedCustomer) ;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnStep2(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> placingOrder.ShipToName = tbShipToName.Text;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> phConfirm.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> lCustomer.Text = placingOrder.OrderedBy.ToString();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span> lShipTo.Text = placingOrder.ShipToName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Cancel(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// give up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> phEnterShipToName.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> StartOver() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> phSelectCustomer.Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> Finish(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> placingOrder.OrderDate = DateTime.Now;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> daoFactory.GetOrderDao().Save(placingOrder);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> bf.CurrentConversation.FinishSpan(); <span style="color:#008000;">//finish up the current spanning conversation</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> placingOrder = <span style="color:#0000ff;">null</span>; <span style="color:#008000;">//reset the placing order to null after conversation is done is a good practice</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> phConfirm.Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 53:</span> StartOver();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 54:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 55:</span> }</pre> </div> </div> <pre> </pre> <p><br />In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br />For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /><b><a href="http://nhcontrib.wiki.sourceforge.net/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/3.aspxSun, 07 Sep 2008 17:31:05 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:63kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<p>&nbsp;</p> <h2 id="tocBurrowIntroduction0"><b>Why Is Burrow Needed?</b></h2> <p> Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br /> Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br /> <br /> The core concept of Burrow is <a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a class="wiki_link_ext" href="http://www.jboss.com/products/seam" rel="nofollow">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br /> For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br /> <br /> OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br /> For more information about Burrow Conversation, <a class="wiki_link" href="/BurrowConversationExplained">click here</a>.</p> <h2 id="tocBurrowIntroduction1">Main Features of Burrow</h2> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction</li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time</li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception.</li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases.</li> </ul> <p>&nbsp;</p> <h2 id="tocBurrowIntroduction2"><b>A Simple Example about Long Conversation</b></h2> <p> To demonstrate Burrow, we used the basic example from the well-known article &quot;<a class="wiki_link_ext" href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20" rel="nofollow">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it:</p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore</li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock</li> </ul> <p> <br /> Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /> <b>PlaceOrder.aspx</b></p> <pre> &lt;asp:PlaceHolder ID=&quot;phSelectCustomer&quot; runat=&quot;server&quot; Visible=&quot;true&quot;&gt;<br /><br /> Select a customer who wants to place an order (will be the OrderBy)&lt;br /&gt;<br /> &lt;asp:DropDownList ID=&quot;ddlCustomers&quot; runat=&quot;server&quot; DataTextField=&quot;ContactName&quot; DataValueField=&quot;ID&quot;&gt;<br /><br /> &lt;/asp:DropDownList&gt;<br /> &lt;asp:Button ID=&quot;btnSelectCustomer&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;Step1&quot; /&gt;<br /><br /> &lt;/asp:PlaceHolder&gt;<br /> &lt;asp:PlaceHolder ID=&quot;phEnterShipToName&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;<br /> Please enter your ship to information:<br /> &lt;asp:TextBox ID=&quot;tbShipToName&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt;<br /><br /> &lt;asp:Button ID=&quot;btnEnterShipTo&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;btnStep2&quot; /&gt;&lt;br /&gt;<br /> &lt;asp:Button ID=&quot;btnCancel&quot; OnClick=&quot;Cancel&quot; runat=&quot;server&quot; Text=&quot;cancel&quot;&gt;&lt;/asp:Button&gt;<br /><br /> &lt;/asp:PlaceHolder&gt;<br /> &lt;asp:PlaceHolder ID=&quot;phConfirm&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;Customer:<br /> &lt;asp:Literal ID=&quot;lCustomer&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt;<br /><br /> &lt;br /&gt;<br /> Ship to:<br /> &lt;asp:Literal ID=&quot;lShipTo&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt;<br /> &lt;br /&gt;<br /> &lt;asp:Button ID=&quot;btnConfirm&quot; runat=&quot;server&quot; Text=&quot;Confirm&quot; OnClick=&quot;Finish&quot; /&gt;<br /><br /> &lt;/asp:PlaceHolder&gt;</pre> <p> <br /> <b>PlaceOrder.aspx.cs</b></p> <pre class="text">public partial class PlaceOrder : Page {<br /> private IDaoFactory daoFactory = new NHibernateDaoFactory();<br /> private BurrowFramework bf = new BurrowFramework();<br />&nbsp;<br /> /// &lt;summary&gt;<br /> /// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation<br /> /// &lt;/summary&gt;<br /><br /> public Order placingOrder {<br /> get { return (Order) bf.CurrentConversation.Items[&quot;placingOrder&quot;]; }<br /> set { bf.CurrentConversation.Items[&quot;placingOrder&quot;] = value; }<br /> }<br />&nbsp;<br /> protected void Page_Load(object sender, EventArgs e) {<br /> if (!IsPostBack) {<br /> ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll();<br /> ddlCustomers.DataBind();<br /> }<br /> }<br />&nbsp;<br /> protected void Step1(object sender, EventArgs e) {<br /> //start an atomic Conversation that span over postbacks<br /> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);<br /> Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, false);<br /> placingOrder = new Order(selectedCustomer) ;<br /> phSelectCustomer.Visible = false;<br /> phEnterShipToName.Visible = true;<br /> }<br />&nbsp;<br /> protected void btnStep2(object sender, EventArgs e) {<br /> placingOrder.ShipToName = tbShipToName.Text;<br /> phEnterShipToName.Visible = false;<br /> phConfirm.Visible = true;<br /> lCustomer.Text = placingOrder.OrderedBy.ToString();<br /> lShipTo.Text = placingOrder.ShipToName;<br /> }<br />&nbsp;<br /> protected void Cancel(object sender, EventArgs e) {<br /> bf.CurrentConversation.GiveUp(); // give up the current spanning conversation<br /> phEnterShipToName.Visible = false;<br /> StartOver();<br /> }<br /><br />&nbsp;<br /> private void StartOver() {<br /> phSelectCustomer.Visible = true;<br /> }<br />&nbsp;<br /> protected void Finish(object sender, EventArgs e) {<br /> placingOrder.OrderDate = DateTime.Now;<br /> daoFactory.GetOrderDao().Save(placingOrder);<br /> bf.CurrentConversation.FinishSpan(); //finish up the current spanning conversation<br /> placingOrder = null; //reset the placing order to null after conversation is done is a good practice<br /> phConfirm.Visible = false;<br /> StartOver();<br /> }<br />}</pre> <p> <br /> In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br /> <br /> For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /> <b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /> <b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /> <b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /> <b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/2.aspxSun, 07 Sep 2008 17:24:05 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:54kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx<p>&lt;!-- google_ad_section_start --&gt; </p> <h2 id="tocBurrowIntroduction0"><b>Why Is Burrow Needed?</b></h2> <p> Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br /> Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br /> <br /> The core concept of Burrow is <a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a class="wiki_link_ext" href="http://www.jboss.com/products/seam" rel="nofollow">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br /> For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br /> <br /> OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br /> For more information about Burrow Conversation, <a class="wiki_link" href="/BurrowConversationExplained">click here</a>.</p> <h2 id="tocBurrowIntroduction1">Main Features of Burrow</h2> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction</li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time</li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception.</li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases.</li> </ul> <p>&nbsp;</p> <h2 id="tocBurrowIntroduction2"><b>A Simple Example about Long Conversation</b></h2> <p> To demonstrate Burrow, we used the basic example from the well-known article &quot;<a class="wiki_link_ext" href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20" rel="nofollow">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it:</p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore</li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock</li> </ul> <p> <br /> Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /> <b>PlaceOrder.aspx</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- --&gt;&lt;/style&gt; </p> <pre> &lt;asp:PlaceHolder ID=&quot;phSelectCustomer&quot; runat=&quot;server&quot; Visible=&quot;true&quot;&gt; Select a customer who wants to place an order (will be the OrderBy)&lt;br /&gt; &lt;asp:DropDownList ID=&quot;ddlCustomers&quot; runat=&quot;server&quot; DataTextField=&quot;ContactName&quot; DataValueField=&quot;ID&quot;&gt; &lt;/asp:DropDownList&gt; &lt;asp:Button ID=&quot;btnSelectCustomer&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;Step1&quot; /&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phEnterShipToName&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt; Please enter your ship to information: &lt;asp:TextBox ID=&quot;tbShipToName&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID=&quot;btnEnterShipTo&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;btnStep2&quot; /&gt;&lt;br /&gt; &lt;asp:Button ID=&quot;btnCancel&quot; OnClick=&quot;Cancel&quot; runat=&quot;server&quot; Text=&quot;cancel&quot;&gt;&lt;/asp:Button&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phConfirm&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;Customer: &lt;asp:Literal ID=&quot;lCustomer&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; Ship to: &lt;asp:Literal ID=&quot;lShipTo&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; &lt;asp:Button ID=&quot;btnConfirm&quot; runat=&quot;server&quot; Text=&quot;Confirm&quot; OnClick=&quot;Finish&quot; /&gt; &lt;/asp:PlaceHolder&gt;</pre> <p> <br /> <b>PlaceOrder.aspx.cs</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .text .imp {font-weight: bold; color: red;} --&gt;&lt;/style&gt; </p> <pre class="text">public partial class PlaceOrder : Page { private IDaoFactory daoFactory = new NHibernateDaoFactory(); private BurrowFramework bf = new BurrowFramework(); &nbsp; /// &lt;summary&gt; /// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation /// &lt;/summary&gt; public Order placingOrder { get { return (Order) bf.CurrentConversation.Items[&quot;placingOrder&quot;]; } set { bf.CurrentConversation.Items[&quot;placingOrder&quot;] = value; } } &nbsp; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll(); ddlCustomers.DataBind(); } } &nbsp; protected void Step1(object sender, EventArgs e) { //start an atomic Conversation that span over postbacks bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction); Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, false); placingOrder = new Order(selectedCustomer) ; phSelectCustomer.Visible = false; phEnterShipToName.Visible = true; } &nbsp; protected void btnStep2(object sender, EventArgs e) { placingOrder.ShipToName = tbShipToName.Text; phEnterShipToName.Visible = false; phConfirm.Visible = true; lCustomer.Text = placingOrder.OrderedBy.ToString(); lShipTo.Text = placingOrder.ShipToName; } &nbsp; protected void Cancel(object sender, EventArgs e) { bf.CurrentConversation.GiveUp(); // give up the current spanning conversation phEnterShipToName.Visible = false; StartOver(); } &nbsp; private void StartOver() { phSelectCustomer.Visible = true; } &nbsp; protected void Finish(object sender, EventArgs e) { placingOrder.OrderDate = DateTime.Now; daoFactory.GetOrderDao().Save(placingOrder); bf.CurrentConversation.FinishSpan(); //finish up the current spanning conversation placingOrder = null; //reset the placing order to null after conversation is done is a good practice phConfirm.Visible = false; StartOver(); } }</pre> <p> <br /> In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br /> <br /> For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /> <b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /> <b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /> <b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /> <b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Introductionhttp://www.nhforge.org/wikis/burrow/introduction/revision/1.aspxSun, 07 Sep 2008 17:19:58 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:52kailuowanghttp://www.nhforge.org/wikis/burrow/introduction/comments.aspx&lt;!-- google_ad_section_start --&gt; <h2 id="tocBurrowIntroduction0"><b>Why Is Burrow Needed?</b></h2> <p> Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br /> Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br /> <br /> The core concept of Burrow is <a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a class="wiki_link_ext" href="http://www.jboss.com/products/seam" rel="nofollow">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br /> For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br /> <br /> OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br /> For more information about Burrow Conversation, <a class="wiki_link" href="/BurrowConversationExplained">click here</a>.<br /></p> <h2 id="tocBurrowIntroduction1">Main Features of Burrow</h2> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction</li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time</li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception.</li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases.</li> </ul> <p>&nbsp;</p> <h2 id="tocBurrowIntroduction2"><b>A Simple Example about Long Conversation</b></h2> <p> To demonstrate Burrow, we used the basic example from the well-known article &quot;<a class="wiki_link_ext" href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20" rel="nofollow">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it:</p> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore</li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock</li> </ul> <p> <br /> Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /> <b>PlaceOrder.aspx</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- --&gt;&lt;/style&gt; </p> <pre> &lt;asp:PlaceHolder ID=&quot;phSelectCustomer&quot; runat=&quot;server&quot; Visible=&quot;true&quot;&gt; Select a customer who wants to place an order (will be the OrderBy)&lt;br /&gt; &lt;asp:DropDownList ID=&quot;ddlCustomers&quot; runat=&quot;server&quot; DataTextField=&quot;ContactName&quot; DataValueField=&quot;ID&quot;&gt; &lt;/asp:DropDownList&gt; &lt;asp:Button ID=&quot;btnSelectCustomer&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;Step1&quot; /&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phEnterShipToName&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt; Please enter your ship to information: &lt;asp:TextBox ID=&quot;tbShipToName&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID=&quot;btnEnterShipTo&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;btnStep2&quot; /&gt;&lt;br /&gt; &lt;asp:Button ID=&quot;btnCancel&quot; OnClick=&quot;Cancel&quot; runat=&quot;server&quot; Text=&quot;cancel&quot;&gt;&lt;/asp:Button&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phConfirm&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;Customer: &lt;asp:Literal ID=&quot;lCustomer&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; Ship to: &lt;asp:Literal ID=&quot;lShipTo&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; &lt;asp:Button ID=&quot;btnConfirm&quot; runat=&quot;server&quot; Text=&quot;Confirm&quot; OnClick=&quot;Finish&quot; /&gt; &lt;/asp:PlaceHolder&gt;</pre> <p> <br /> <b>PlaceOrder.aspx.cs</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .text .imp {font-weight: bold; color: red;} --&gt;&lt;/style&gt; </p> <pre class="text">public partial class PlaceOrder : Page { private IDaoFactory daoFactory = new NHibernateDaoFactory(); private BurrowFramework bf = new BurrowFramework(); &nbsp; /// &lt;summary&gt; /// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation /// &lt;/summary&gt; public Order placingOrder { get { return (Order) bf.CurrentConversation.Items[&quot;placingOrder&quot;]; } set { bf.CurrentConversation.Items[&quot;placingOrder&quot;] = value; } } &nbsp; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll(); ddlCustomers.DataBind(); } } &nbsp; protected void Step1(object sender, EventArgs e) { //start an atomic Conversation that span over postbacks bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction); Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, false); placingOrder = new Order(selectedCustomer) ; phSelectCustomer.Visible = false; phEnterShipToName.Visible = true; } &nbsp; protected void btnStep2(object sender, EventArgs e) { placingOrder.ShipToName = tbShipToName.Text; phEnterShipToName.Visible = false; phConfirm.Visible = true; lCustomer.Text = placingOrder.OrderedBy.ToString(); lShipTo.Text = placingOrder.ShipToName; } &nbsp; protected void Cancel(object sender, EventArgs e) { bf.CurrentConversation.GiveUp(); // give up the current spanning conversation phEnterShipToName.Visible = false; StartOver(); } &nbsp; private void StartOver() { phSelectCustomer.Visible = true; } &nbsp; protected void Finish(object sender, EventArgs e) { placingOrder.OrderDate = DateTime.Now; daoFactory.GetOrderDao().Save(placingOrder); bf.CurrentConversation.FinishSpan(); //finish up the current spanning conversation placingOrder = null; //reset the placing order to null after conversation is done is a good practice phConfirm.Visible = false; StartOver(); } }</pre> <p> <br /> In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br /> <br /> For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /> <b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /> <b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /> <b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /> <b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is.</p>Examplehttp://www.nhforge.org/wikis/burrow/example/revision/2.aspxSun, 07 Sep 2008 19:08:13 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:98kailuowanghttp://www.nhforge.org/wikis/burrow/example/comments.aspx<p>This example will show how NHibernate.Burrow and NHibernate.Burrow.AppBlock simplifies ASP.NET/NHibernate application development on a day-to-day basis. The full code is available in NHContrib/src/NHibernate.Burrow/examples/BasicThreeTier.<br />This simple example is about managing an entity called &quot;Customer&quot;.</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Customer</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> address;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> companyName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> contactName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> id;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">bool</span> isActivated;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">decimal</span> salesPotential;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> <span style="color:#0000ff;">private</span> Customer(){}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> <span style="color:#0000ff;">public</span> Customer(<span style="color:#0000ff;">string</span> contactName)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> ContactName = contactName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Id</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> get { <span style="color:#0000ff;">return</span> id; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">private</span> set { id = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> Address</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> get { <span style="color:#0000ff;">return</span> address; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> set { address = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">decimal</span> SalesPotential</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> get { <span style="color:#0000ff;">return</span> salesPotential; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> set { salesPotential = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">bool</span> IsActivated</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> get { <span style="color:#0000ff;">return</span> isActivated; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> set { isActivated = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> CompanyName</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> get { <span style="color:#0000ff;">return</span> companyName; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> set { companyName = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> ContactName</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> get { <span style="color:#0000ff;">return</span> contactName; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> set { contactName = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> }</pre> </div> </div> <p><br />The mapping file as follows</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">hibernate-mapping</span> <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">=&quot;urn:nhibernate-mapping-2.2&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">class</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;BasicThreeTier.Core.Domain.Customer, BasicThreeTier.Core&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">table</span><span style="color:#0000ff;">=&quot;Customers&quot;</span> <span style="color:#ff0000;">lazy</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">id</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;Id&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">generator</span> <span style="color:#ff0000;">class</span><span style="color:#0000ff;">=&quot;identity&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">id</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">class</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">hibernate-mapping</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>The first step will be creating a DAO for it. Here we create one by inheriting the DAO base from NHibernate.AppBlock</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> CustomerDAO : NHibernate.Burrow.AppBlock.DAOBases.GenericDAO&lt;Customer&gt;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{}</pre> </div> </div> <p>The DAO base class provides a lot of functions including CRUD and much more. But this inheritance is by no means mandatory. You can always use your own DAO.<br />Now the domain layer is ready. Let&#39;s create a page that lists all the all the customer entities in a grid view that is sortable and paged (both at DB side).<br /><b>ListCustomer.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:GridView</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;grdCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">AutoGenerateColumns</span><span style="color:#0000ff;">=&quot;false&quot;</span> <span style="color:#ff0000;">AllowPaging</span><span style="color:#0000ff;">=&quot;True&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">AllowSorting</span><span style="color:#0000ff;">=&quot;True&quot;</span> <span style="color:#ff0000;">PageSize</span><span style="color:#0000ff;">=&quot;5&quot;</span> <span style="color:#ff0000;">DataSourceID</span><span style="color:#0000ff;">=&quot;odsAll&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Columns</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TemplateField</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Customer ID&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;Id&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ItemTemplate</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:LinkButton</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lbtSelect&quot;</span> <span style="color:#ff0000;">OnCommand</span><span style="color:#0000ff;">=&quot;lbt_SelectCommand&quot;</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">CommandArgument</span><span style="color:#0000ff;">=&#39;&lt;%# Eval(&quot;Id&quot;) %&gt;&#39;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;</span><pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> <span style="background-color:#ffff00;">&lt;%</span>1:</span> # Eval(<span style="color:#006080;">&quot;Id&quot;</span>) <span style="background-color:#ffff00;">%&gt;</span></pre> <span style="color:#0000ff;"> &lt;/</span><span style="color:#800000;">asp:LinkButton</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ItemTemplate</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:TemplateField</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Company Name&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Contact Name&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Sales Potential&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">HtmlEncodeFormatString</span><span style="color:#0000ff;">=&quot;true&quot;</span> <span style="color:#ff0000;">DataFormatString</span><span style="color:#0000ff;">=&quot;{0:C}&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Activated&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Columns</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:GridView</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:ObjectDataSource</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;odsAll&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">TypeName</span><span style="color:#0000ff;">=&quot;BasicThreeTier.Core.Dao.CustomerDAO&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">EnablePaging</span><span style="color:#0000ff;">=&quot;True&quot;</span> <span style="color:#ff0000;">MaximumRowsParameterName</span><span style="color:#0000ff;">=&quot;pageSize&quot;</span> <span style="color:#ff0000;">StartRowIndexParameterName</span><span style="color:#0000ff;">=&quot;startRow&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">SortParameterName</span><span style="color:#0000ff;">=&quot;sortExpression&quot;</span> <span style="color:#ff0000;">SelectMethod</span><span style="color:#0000ff;">=&quot;FindAll&quot;</span> <span style="color:#ff0000;">SelectCountMethod</span><span style="color:#0000ff;">=&quot;CountAll&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:ObjectDataSource</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">uc1:EditCustomer</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;EditCustomer1&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span> <span style="color:#ff0000;">OnUpdated</span><span style="color:#0000ff;">=&quot;EditCustomer_Updated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> </div> </div> <p>The EditCustomer1 is a user control that we created to edit one customer, we&#39;ll talk about it later.<br /><b>ListCustomer.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> ListCustomers : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> lbt_SelectCommand(<span style="color:#0000ff;">object</span> sender, CommandEventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> EditCustomer1.Bind(<span style="color:#0000ff;">new</span> CustomerDAO().Get(<span style="color:#0000ff;">int</span>.Parse(e.CommandArgument.ToString()))); <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> EditCustomer_Updated(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> grdCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>The code behind may look like an excerpt, but it&#39;s not. It&#39;s just simple as that, we have a paged and sortable (both at Database side) gridview that lists all customers. The inherited DAO together with the ObjectDataSource take care of all the tedious work of the DB side sorting and paging. In the code behind, we only need two simple methods for binding the selected customer to the EditCustomer control and refresh the gridview when customer is modified in that control.<br />Now let&#39;s look at the EditCustomer user control.<br /><b>EditCustomer.ascx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span>Edit Customer<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Customer ID:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Label</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lblCustomerID&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Company Name:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtCompanyName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Contact Name:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtContactName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Address:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtAddress&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Sales Potential:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtSalesPotential&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Activated:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:CheckBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;cbActivated&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBinder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;DataBinder&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DefaultBindingSource</span><span style="color:#0000ff;">=&quot;customer&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">DataBindingItems</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiId&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">BindingMode</span><span style="color:#0000ff;">=&quot;oneway&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;lblCustomerID&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;Id&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiCompanyName&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtCompanyName&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiContactName&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtContactName&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiAddress&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtAddress&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiSP&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtSalesPotential&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">DisplayFormat</span><span style="color:#0000ff;">=&quot;{0:C}&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiIA&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;cbActivated&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">BindingProperty</span><span style="color:#0000ff;">=&quot;Checked&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">DataBindingItems</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ww:wwDataBinder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnUpdate&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnUpdate_OnClick&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Update&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnCancel_OnClick&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> </div> </div> <p>The wwDataBinder here is an optional 3rd party control that realizes Two-way databinding between UI controls and properties of the code behind class. This wonderful control is created by Rick Strahl. It eliminates the code that transfer values between form control values and entity properties. Detailed information about it can be found <a href="http://msdn.microsoft.com/en-us/magazine/cc163505.aspx">here</a>. Again, this control is not mandatory by NHibernate.Burrow.<br />Now let&#39;s look at the code behind.<br /><b>EditCustomer.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> EditCustomer : UserControl {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">event</span> EventHandler Updated;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> [EntityField] <span style="color:#0000ff;">protected</span> Customer customer; <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Bind(Customer c) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> customer = c;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> DataBinder.DataBind(<span style="color:#0000ff;">this</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> } <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnUpdate_OnClick(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> DataBinder.Unbind(<span style="color:#0000ff;">this</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">if</span> (Updated != <span style="color:#0000ff;">null</span>)Updated(<span style="color:#0000ff;">this</span>, <span style="color:#0000ff;">new</span> EventArgs());</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> } <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnCancel_OnClick(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> customer = <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> }</pre> </div> </div> <p>Again, this is the complete code that is necessary to manage all the properties for the customer entity.<br />Now with the code listed here we created a three tier application that can list and manage all the customers in DB. As you can see here, the code is very straightforward and clean. No DB related management code anywhere, not even NHibernate is mentioned.<br /><b>Conclusion</b><br />This example demonstrated that other than the advanced features, such as <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">conversation</a>, it provides, NHibernate.Burrow also greatly frees the developers from DB/NHibernate related concerns and thus enable them to focus mostly on project vised logic in their day-to-day development.</p>BurrowExamplehttp://www.nhforge.org/wikis/burrow/example/revision/1.aspxSun, 07 Sep 2008 18:41:00 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:71kailuowanghttp://www.nhforge.org/wikis/burrow/example/comments.aspx<p>This example will show how NHibernate.Burrow and NHibernate.Burrow.AppBlock simplifies ASP.NET/NHibernate application development on a day-to-day basis. The full code is available in NHContrib/src/NHibernate.Burrow/examples/BasicThreeTier.<br />This simple example is about managing an entity called &quot;Customer&quot;.</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Customer</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> address;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> companyName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">string</span> contactName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> id;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">bool</span> isActivated;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">decimal</span> salesPotential;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> <span style="color:#0000ff;">private</span> Customer(){}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> <span style="color:#0000ff;">public</span> Customer(<span style="color:#0000ff;">string</span> contactName)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> ContactName = contactName;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 15:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 16:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 17:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Id</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 18:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 19:</span> get { <span style="color:#0000ff;">return</span> id; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 20:</span> <span style="color:#0000ff;">private</span> set { id = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 21:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 22:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 23:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> Address</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 24:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 25:</span> get { <span style="color:#0000ff;">return</span> address; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 26:</span> set { address = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 27:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 28:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 29:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">decimal</span> SalesPotential</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 30:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 31:</span> get { <span style="color:#0000ff;">return</span> salesPotential; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 32:</span> set { salesPotential = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 33:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 34:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 35:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">bool</span> IsActivated</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 36:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 37:</span> get { <span style="color:#0000ff;">return</span> isActivated; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 38:</span> set { isActivated = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 39:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 40:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 41:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> CompanyName</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 42:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 43:</span> get { <span style="color:#0000ff;">return</span> companyName; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 44:</span> set { companyName = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 45:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 46:</span>&nbsp; </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 47:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> ContactName</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 48:</span> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 49:</span> get { <span style="color:#0000ff;">return</span> contactName; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 50:</span> set { contactName = <span style="color:#0000ff;">value</span>; }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 51:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 52:</span> }</pre> </div> </div> <p><br />The mapping file as follows</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">hibernate-mapping</span> <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">=&quot;urn:nhibernate-mapping-2.2&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">class</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;BasicThreeTier.Core.Domain.Customer, BasicThreeTier.Core&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">table</span><span style="color:#0000ff;">=&quot;Customers&quot;</span> <span style="color:#ff0000;">lazy</span><span style="color:#0000ff;">=&quot;false&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">id</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;Id&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">generator</span> <span style="color:#ff0000;">class</span><span style="color:#0000ff;">=&quot;identity&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">id</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">property</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">class</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">hibernate-mapping</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>The first step will be creating a DAO for it. Here we create one by inheriting the DAO base from NHibernate.AppBlock</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> CustomerDAO : NHibernate.Burrow.AppBlock.DAOBases.GenericDAO&lt;Customer&gt;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{}</pre> </div> </div> <p>The DAO base class provides a lot of functions including CRUD and much more. But this inheritance is by no means mandatory. You can always use your own DAO.<br />Now the domain layer is ready. Let&#39;s create a page that lists all the all the customer entities in a grid view that is sortable and paged (both at DB side).<br /><b>ListCustomer.aspx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:GridView</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;grdCustomers&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">AutoGenerateColumns</span><span style="color:#0000ff;">=&quot;false&quot;</span> <span style="color:#ff0000;">AllowPaging</span><span style="color:#0000ff;">=&quot;True&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">AllowSorting</span><span style="color:#0000ff;">=&quot;True&quot;</span> <span style="color:#ff0000;">PageSize</span><span style="color:#0000ff;">=&quot;5&quot;</span> <span style="color:#ff0000;">DataSourceID</span><span style="color:#0000ff;">=&quot;odsAll&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Columns</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TemplateField</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Customer ID&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;Id&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ItemTemplate</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:LinkButton</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lbtSelect&quot;</span> <span style="color:#ff0000;">OnCommand</span><span style="color:#0000ff;">=&quot;lbt_SelectCommand&quot;</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">CommandArgument</span><span style="color:#0000ff;">=&#39;&lt;%# Eval(&quot;Id&quot;) %&gt;&#39;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span><span style="color:#0000ff;">&gt;</span><pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> <span style="background-color:#ffff00;">&lt;%</span>1:</span> # Eval(<span style="color:#006080;">&quot;Id&quot;</span>) <span style="background-color:#ffff00;">%&gt;</span></pre> <span style="color:#0000ff;"> &lt;/</span><span style="color:#800000;">asp:LinkButton</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ItemTemplate</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:TemplateField</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Company Name&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Contact Name&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Sales Potential&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">HtmlEncodeFormatString</span><span style="color:#0000ff;">=&quot;true&quot;</span> <span style="color:#ff0000;">DataFormatString</span><span style="color:#0000ff;">=&quot;{0:C}&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:BoundField</span> <span style="color:#ff0000;">DataField</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#ff0000;">HeaderText</span><span style="color:#0000ff;">=&quot;Activated&quot;</span> <span style="color:#ff0000;">SortExpression</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Columns</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:GridView</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:ObjectDataSource</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;odsAll&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">TypeName</span><span style="color:#0000ff;">=&quot;BasicThreeTier.Core.Dao.CustomerDAO&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">EnablePaging</span><span style="color:#0000ff;">=&quot;True&quot;</span> <span style="color:#ff0000;">MaximumRowsParameterName</span><span style="color:#0000ff;">=&quot;pageSize&quot;</span> <span style="color:#ff0000;">StartRowIndexParameterName</span><span style="color:#0000ff;">=&quot;startRow&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#ff0000;">SortParameterName</span><span style="color:#0000ff;">=&quot;sortExpression&quot;</span> <span style="color:#ff0000;">SelectMethod</span><span style="color:#0000ff;">=&quot;FindAll&quot;</span> <span style="color:#ff0000;">SelectCountMethod</span><span style="color:#0000ff;">=&quot;CountAll&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">asp:ObjectDataSource</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">uc1:EditCustomer</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;EditCustomer1&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">Visible</span><span style="color:#0000ff;">=&quot;false&quot;</span> <span style="color:#ff0000;">OnUpdated</span><span style="color:#0000ff;">=&quot;EditCustomer_Updated&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> </div> </div> <p>The EditCustomer1 is a user control that we created to edit one customer, we&#39;ll talk about it later.<br /><b>ListCustomer.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> ListCustomers : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> lbt_SelectCommand(<span style="color:#0000ff;">object</span> sender, CommandEventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> EditCustomer1.Bind(<span style="color:#0000ff;">new</span> CustomerDAO().Get(<span style="color:#0000ff;">int</span>.Parse(e.CommandArgument.ToString()))); <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> EditCustomer_Updated(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> grdCustomers.DataBind();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>The code behind may look like an excerpt, but it&#39;s not. It&#39;s just simple as that, we have a paged and sortable (both at Database side) gridview that lists all customers. The inherited DAO together with the ObjectDataSource take care of all the tedious work of the DB side sorting and paging. In the code behind, we only need two simple methods for binding the selected customer to the EditCustomer control and refresh the gridview when customer is modified in that control.<br />Now let&#39;s look at the EditCustomer user control.<br /><b>EditCustomer.ascx</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span>Edit Customer<span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">h2</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Customer ID:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Label</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;lblCustomerID&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Company Name:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtCompanyName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Contact Name:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtContactName&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Address:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtAddress&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">Sales Potential:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:TextBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;txtSalesPotential&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">Activated:<span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:CheckBox</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;cbActivated&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;&lt;</span><span style="color:#800000;">br</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBinder</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;DataBinder&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">DefaultBindingSource</span><span style="color:#0000ff;">=&quot;customer&quot;</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">DataBindingItems</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiId&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">BindingMode</span><span style="color:#0000ff;">=&quot;oneway&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;lblCustomerID&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;Id&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiCompanyName&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;CompanyName&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtCompanyName&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiContactName&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;ContactName&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtContactName&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiAddress&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;Address&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtAddress&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiSP&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;SalesPotential&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;txtSalesPotential&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">DisplayFormat</span><span style="color:#0000ff;">=&quot;{0:C}&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">ww:wwDataBindingItem</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;dbiIA&quot;</span> <span style="color:#ff0000;">BindingSourceMember</span><span style="color:#0000ff;">=&quot;IsActivated&quot;</span> <span style="color:#ff0000;">ControlId</span><span style="color:#0000ff;">=&quot;cbActivated&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#ff0000;">BindingProperty</span><span style="color:#0000ff;">=&quot;Checked&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">DataBindingItems</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">ww:wwDataBinder</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnUpdate&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnUpdate_OnClick&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Update&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">asp:Button</span> <span style="color:#ff0000;">ID</span><span style="color:#0000ff;">=&quot;btnCancel&quot;</span> <span style="color:#ff0000;">runat</span><span style="color:#0000ff;">=&quot;server&quot;</span> <span style="color:#ff0000;">OnClick</span><span style="color:#0000ff;">=&quot;btnCancel_OnClick&quot;</span> <span style="color:#ff0000;">Text</span><span style="color:#0000ff;">=&quot;Cancel&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> </div> </div> <p>The wwDataBinder here is an optional 3rd party control that realizes Two-way databinding between UI controls and properties of the code behind class. This wonderful control is created by Rick Strahl. It eliminates the code that transfer values between form control values and entity properties. Detailed information about it can be found <a href="http://msdn.microsoft.com/en-us/magazine/cc163505.aspx">here</a>. Again, this control is not mandatory by NHibernate.Burrow.<br />Now let&#39;s look at the code behind.<br /><b>EditCustomer.aspx.cs</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> EditCustomer : UserControl {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">event</span> EventHandler Updated;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> [EntityField] <span style="color:#0000ff;">protected</span> Customer customer; <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Bind(Customer c) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> customer = c;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> DataBinder.DataBind(<span style="color:#0000ff;">this</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> Visible = <span style="color:#0000ff;">true</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> } <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnUpdate_OnClick(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> DataBinder.Unbind(<span style="color:#0000ff;">this</span>);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">if</span> (Updated != <span style="color:#0000ff;">null</span>)Updated(<span style="color:#0000ff;">this</span>, <span style="color:#0000ff;">new</span> EventArgs());</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 10:</span> } <span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> btnCancel_OnClick(<span style="color:#0000ff;">object</span> sender, EventArgs e) {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 11:</span> customer = <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 12:</span> Visible = <span style="color:#0000ff;">false</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 13:</span> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 14:</span> }</pre> </div> </div> <p>Again, this is the complete code that is necessary to manage all the properties for the customer entity.<br />Now with the code listed here we created a three tier application that can list and manage all the customers in DB. As you can see here, the code is very straightforward and clean. No DB related management code anywhere, not even NHibernate is mentioned.<br /><b>Conclusion</b><br />This example demonstrated that other than the advanced features, such as <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">conversation</a>, it provides, NHibernate.Burrow also greatly frees the developers from DB/NHibernate related concerns and thus enable them to focus mostly on project vised logic in their day-to-day development.</p> Get Startedhttp://www.nhforge.org/wikis/burrow/get-started/revision/13.aspxSun, 07 Sep 2008 21:20:14 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:97tehlikehttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><strong>Configration setting in the Config file:</strong></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:150px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:60px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:170px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:30px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession();<span style="color:#008000;"> //Gets the Burrow Managed NHibernate Session</span></pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:50px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;"><span style="color:#0000ff;">new</span></span><span style="color:#0000ff;"> </span>BurrowFramework.InitWorkSpace();//call this at the beginning (only when not in ASP.NET)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;"><span style="color:#0000ff;">new</span></span><span style="color:#0000ff;"> </span>BurrowFramework.CloseWorkSpace();//call this at the end (only when not in ASP.NET)</pre> </div> </div> Get Startedhttp://www.nhforge.org/wikis/burrow/get-started/revision/12.aspxSun, 07 Sep 2008 20:53:37 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:84Fabio Maulohttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><strong>Configration setting in the Config file:</strong></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:150px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:60px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:170px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:30px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession();<span style="color:#008000;"> //Gets the Burrow Managed NHibernate Session</span></pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:50px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace();<span style="color:#008000;">//call this at the end (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div> </div> Get Startedhttp://www.nhforge.org/wikis/burrow/get-started/revision/11.aspxSun, 07 Sep 2008 19:42:55 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:83kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this: </p> <p>&nbsp;</p> <p>&nbsp;</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session</pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace();<span style="color:#008000;">// //call this at the end (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div> </div>BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/10.aspxSun, 07 Sep 2008 17:55:19 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:74kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this: </p> <p>&nbsp;</p> <p>&nbsp;</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session</pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace();<span style="color:#008000;">// //call this at the end (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div> </div>BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/9.aspxSun, 07 Sep 2008 17:55:19 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:70kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this: </p> <p>&nbsp;</p> <p>&nbsp;</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session</pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace();<span style="color:#008000;">// //call this at the end (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div> </div>Get Startedhttp://www.nhforge.org/wikis/burrow/get-started/revision/8.aspxSun, 07 Sep 2008 17:54:52 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:62kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:173px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnit1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p>For web.config in ASP.NET applications, you also need to add a HttpModule Setting </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:117px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a href="http://nhcontrib.wiki.sourceforge.net/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this: </p> <p>&nbsp;</p> <p>&nbsp;</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:206px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">section</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow&quot;</span> <span style="color:#ff0000;">type</span><span style="color:#0000ff;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 6:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB1&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db1hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 7:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">add</span> <span style="color:#ff0000;">name</span><span style="color:#0000ff;">=&quot;PersistenceUnitDB2&quot;</span> <span style="color:#ff0000;">nh-config-file</span><span style="color:#0000ff;">=&quot;db2hibernate.cfg.xml&quot;</span> <span style="color:#0000ff;">/&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 8:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 9:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:63px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session</pre> </div> </div> <p>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;height:92px;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace();<span style="color:#008000;">// //call this at the end (only when not in ASP.NET)</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div> </div>Get Startedhttp://www.nhforge.org/wikis/burrow/get-started/revision/7.aspxSun, 07 Sep 2008 17:48:11 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:61Fabio Maulohttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><strong>Configration setting in the Config file:</strong></p> <div class="wlWriterEditableSmartContent" id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:20218a66-ce11-442a-b8d3-9c5178002c6f" style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px;"> <pre style="width:100%;"><div><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">section </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow&quot;</span><span style="color:#FF0000;"> type</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">NHibernate.Burrow </span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">add </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;PersistenceUnit1&quot;</span><span style="color:#FF0000;"> nh-config-file</span><span style="color:#0000FF;">=&quot;hibernate.cfg.xml&quot;</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000FF;">&gt;</span></div></pre> </div> <div class="wiki">For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br /> <div class="wlWriterEditableSmartContent" id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:b63fc07f-1cd0-4165-a769-5a8c2c1bbdd7" style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px;"> <pre style="width:100%;"><div><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">httpModules</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">add </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><span style="color:#FF0000;"> type</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">httpModules</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span></div></pre> </div> </div> <div class="wiki">You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:</div> <div class="wlWriterEditableSmartContent" id="scid:F2210F5F-69EB-4d4c-AFF7-B8A050E9CC72:4c9f981b-9085-49f3-b6f5-33a9c1e02e07" style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px;"> <pre style="width:100%;"><div><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">configSections</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">section </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow&quot;</span><span style="color:#FF0000;"> type</span><span style="color:#0000FF;">=&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">configSections</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">NHibernate.Burrow </span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">add </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;PersistenceUnitDB1&quot;</span><span style="color:#FF0000;"> nh-config-file</span><span style="color:#0000FF;">=&quot;db1hibernate.cfg.xml&quot;</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">add </span><span style="color:#FF0000;">name</span><span style="color:#0000FF;">=&quot;PersistenceUnitDB2&quot;</span><span style="color:#FF0000;"> nh-config-file</span><span style="color:#0000FF;">=&quot;db2hibernate.cfg.xml&quot;</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">persistantUnits</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;"> </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000FF;">&gt;</span></div></pre> </div> <div class="wiki">&nbsp;</div> <div class="wiki">That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line</div> <div> <pre style="font-size:8pt;margin:0em;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, &#39;Courier New&#39;, courier, monospace;background-color:#f4f4f4;border-style:none;padding:0px;">ISession sess = <span style="color:#0000ff;">new</span> BurrowFramework().GetSession(); //Gets the Burrow Managed NHibernate Session</pre> </div> <div>&nbsp;</div> <div>Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service</div> <div> <pre style="font-size:8pt;margin:0em;overflow:visible;width:100%;color:black;line-height:12pt;font-family:consolas, &#39;Courier New&#39;, courier, monospace;background-color:#f4f4f4;border-style:none;padding:0px;"><span style="color:#008000;">//call this at the beginning (only when not in ASP.NET)</span> <span style="color:#0000ff;">new</span> BurrowFramework.InitWorkSpace(); <span style="color:#008000;">//call this at the end (only when not in ASP.NET)</span> <span style="color:#0000ff;">new</span> BurrowFramework.CloseWorkSpace();</pre> </div>BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/6.aspxSun, 07 Sep 2008 17:40:11 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:60kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><strong>Configration setting in the Config file:</strong></p> <div class="wiki" id="content_view"> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnit1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br /><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"><span class="sc3"><span class="re1">&lt;httpModules<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/httpModules<span class="re2">&gt;</span></span></span></pre> <br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db1hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB2&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db2hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .csharp .imp {font-weight: bold; color: red;} .csharp .kw1 {color: #0600FF;} .csharp .kw2 {color: #FF8000; font-weight: bold;} .csharp .kw3 {color: #008000;} .csharp .kw4 {color: #FF0000;} .csharp .kw5 {color: #000000;} .csharp .co1 {color: #008080; font-style: italic;} .csharp .co2 {color: #008080;} .csharp .coMULTI {color: #008080; font-style: italic;} .csharp .es0 {color: #008080; font-weight: bold;} .csharp .br0 {color: #008000;} .csharp .st0 {color: #808080;} .csharp .nu0 {color: #FF0000;} .csharp .me1 {color: #0000FF;} .csharp .me2 {color: #0000FF;} --&gt; &lt;/style&gt; <pre class="csharp">ISession sess = <span class="kw3">new</span> BurrowFramework<span class="br0">(</span><span class="br0">)</span>.<span class="me1">GetSession</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//Gets the Burrow Managed NHibernate Session</span></pre> Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .text .imp {font-weight: bold; color: red;} --&gt; &lt;/style&gt; <pre class="text">//call this at the beginning (only when not in ASP.NET)<br /> new BurrowFramework.InitWorkSpace();//<br />&nbsp;<br />//call this at the end (only when not in ASP.NET)<br /> new BurrowFramework.CloseWorkSpace();</pre> &lt;!-- google_ad_section_end --&gt;</div>BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/5.aspxSun, 07 Sep 2008 17:39:28 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:59kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx&lt;!-- ~ SourceForge.net: Create, Participate, Evaluate ~ Copyright (c) 1999-2008 SourceForge, Inc. All rights reserved. --&gt; <p> &lt;link rel=&quot;search&quot; href=&quot;http://www.wiki.sourceforge.net/space/opensearch&quot; type=&quot;application/opensearchdescription+xml&quot; title=&quot;Wikispaces Search&quot; /&gt; &lt;link rel=&quot;search&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/space/opensearch&quot; type=&quot;application/opensearchdescription+xml&quot; title=&quot;Wikispaces Search (nhcontrib Space)&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;http://www.wiki.sourceforge.net/stylesheet/view/www&quot; type=&quot;text/css&quot; /&gt; &lt;link rel=&quot;alternate&quot; title=&quot;nhcontrib : BurrowIntroduction - Edits&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/page/xml/BurrowIntroduction?v=rss_2_0&quot; type=&quot;application/rss+xml&quot; /&gt; &lt;link rel=&quot;alternate&quot; title=&quot;nhcontrib : BurrowIntroduction - Discussion&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/message/xml/BurrowIntroduction?v=rss_2_0&quot; type=&quot;application/rss+xml&quot; /&gt; &lt;link rel=&quot;alternate&quot; title=&quot;nhcontrib - All Changes&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/space/xmla?v=rss_2_0&quot; type=&quot;application/rss+xml&quot; /&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.wiki.sourceforge.net/_/2007033001/s/js/common.js&quot;&gt;&lt;/script&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt; &lt;meta name=&quot;description&quot; content=&quot;The world's largest development and download repository of Open Source code and applications&quot; /&gt; &lt;meta name=&quot;keywords&quot; content=&quot;Open Source, Development, Developers, Projects, Downloads, OSTG, VA Software, SF.net, SourceForge&quot; /&gt; &lt;meta http-equiv=&quot;X-XRDS-Location&quot; content=&quot;http://sourceforge.net/account/xrds.php&quot; /&gt; &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;SourceForge.net Project News&quot; href=&quot;http://sourceforge.net/export/rss2_sfnews.php?group_id=1&amp;amp;rss_fulltext=1&quot; /&gt; &lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;SourceForge.net News&quot; href=&quot;http://sourceforge.net/export/rss2_projnews.php?group_id=141424&amp;amp;rss_fulltext=1&quot; /&gt; &lt;title&gt;SourceForge.net: nhcontrib &raquo; BurrowIntroduction &lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://static.sourceforge.net/css/sfx.php?secure=0&amp;amp;20080417-1657&quot; media=&quot;screen&quot; title=&quot;SFx&quot; /&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/include/jquery/jquery-1.2.3.pack.js&quot;&gt;&lt;/script&gt; </p> &lt;!-- BEGIN: AdSolution-Tag 4.2: Global-Code [PLACE IN HTML-HEAD-AREA!] --&gt; &lt;!-- DoubleClick Random Number --&gt; <p> &lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;&lt;!-- dfp_ord=Math.random()*10000000000000000; dfp_tile = 1; // --&gt;&lt;/script&gt; </p> &lt;!-- End DoubleClick Random Number --&gt; <p> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- ostg_skip = 0; var sourceforge_project_name = 'alexandria'; // --&gt;&lt;/script&gt; </p> &lt;!-- END: AdSolution-Tag 4.2: Global-Code --&gt; &lt;!-- End OSDN NavBar gid: 1 keywords: alexandria,os_groups,independent,php,dynamic,www,internet: --&gt; <p> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var immersion_adcode = &quot;&quot;; var adid = &quot;&quot;; // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- //&lt;![CDATA[ var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('type', 'text/css'); link.setAttribute('href', 'http://static.sourceforge.net/css/sfxjs.php?secure=0&amp;amp;20080417-1657'); document.getElementsByTagName('head')[0].appendChild(link); function help_window(helpurl) { HelpWin = window.open( 'http://sourceforge.net' + helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400'); } // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- //&lt;![CDATA[ jQuery.noConflict(); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/include/thickbox/goods.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/include/js/Util.js&quot;&gt;&lt;/script&gt; </p> &lt;!--pageid wiki_export_theme --&gt; <p> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- //&lt;![CDATA[ jQuery(document).ready(function(){ if(jQuery.browser.msie || jQuery.browser.mozilla ){ jQuery('div.firstwave li ul').append(&quot;&lt;iframe src=&quot;\&quot; mce_src=&quot;/wikis/burrow/burrowgetstarted/edit.aspx/\&quot;&quot;BLOCKED SCRIPTfalse\&quot;&gt;&lt;/iframe&gt;&quot;); jQuery(&#39;#fad36 li ul&#39;).append(&#39;&lt;iframe src=&quot;\&quot; mce_src=&quot;/wikis/burrow/burrowgetstarted/edit.aspx/\&quot;&quot;BLOCKED SCRIPTfalse\&quot;&gt;&lt;/iframe&gt;&#39;); }; }); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/include/thickbox/thickbox.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/include/thickbox/dialog.js&quot;&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://static.sourceforge.net/include/thickbox/thickbox.php?secure=0&amp;amp;20080417-1657&quot; media=&quot;screen&quot; title=&quot;SFx&quot; /&gt; </p> &lt;!--[if IE]&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;http://static.sourceforge.net/css/iestyles.php?secure=0&amp;amp;20080417-1657&quot; mce_href=&quot;http://static.sourceforge.net/css/iestyles.php?secure=0&amp;amp;20080417-1657&quot; /&gt; &lt;![endif]--&gt; <p> &lt;script type=&quot;text/javascript&quot; src=&quot;http://static.sourceforge.net/sfx.js&quot;&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://static.sourceforge.net/css/print.php?secure=0&amp;amp;20080417-1657&quot; media=&quot;print&quot; /&gt; </p> &lt;!-- after META tags --&gt; <p> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var sf_net_pageid = &quot;wiki_export_theme&quot;; var google_hints = &quot;pdf,Delphi,php,crm,emule,backup,GIMP,gaim,python,cms,cad,project management,erp,java,vnc, ,FileZilla,ares,j2me,portable,inventory,flash,FTP,symbian,nagios&quot;; // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;); document.write(unescape(&quot;%3Cscript src='&quot; + gaJsHost + &quot;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&quot;)); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var pageTracker = _gat._getTracker(&quot;UA-32013-6&quot;); var external_pageTracker = _gat._getTracker(&quot;UA-5239675-1&quot;); pageTracker._initData(); // --&gt;&lt;/script&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;http://www.wiki.sourceforge.net/s/sf_theme.css&quot; type=&quot;text/css&quot; /&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;http://www.wiki.sourceforge.net/_/2007033001/s/internal.css&quot; type=&quot;text/css&quot; /&gt; </p> <div id="hd"> <h1> <a href="http://sourceforge.net/">SourceForge.net</a> </h1> <ul class="jump"> <li><a>Jump to main content</a></li> <li><a>Jump to project navigation</a></li> <li><a href="http://sourceforge.net/project/showfiles.php?group_id=1#downloads">Jump to downloads for SourceForge.net</a></li> </ul> <div id="topuser"> <a href="https://sourceforge.net/account/login.php" title="Log in and gain access to additional features including the Marketplace">Log in</a> <a href="http://sourceforge.net/account/registration/" title="Get a SourceForge.net account">Create Account</a> <a href="http://sourceforge.net/support/getsupport.php" title="Get help and support on SourceForge.net">Help</a> </div> </div> <ul id="mainnav"> <li><a href="http://sourceforge.net/">Home</a></li> <li class="selected"><a href="http://sourceforge.net/softwaremap/">Browse&nbsp;Software</a></li> <li class="new"><a href="http://sourceforge.net/services/buy/index.php">Marketplace<sup><b>NEW</b></sup></a></li> <li><a href="http://sourceforge.net/community/">Community</a></li> <li><a href="http://sourceforge.net/register-project/">Create&nbsp;Project</a></li> <li><a href="http://jobs.sourceforge.net">Jobs</a></li> </ul> <div id="kahuna"> &lt;form action=&quot;http://sourceforge.net/search/&quot; method=&quot;get&quot; name=&quot;searchform&quot;&gt; &lt;input name=&quot;type_of_search&quot; value=&quot;soft&quot; type=&quot;hidden&quot; /&gt; &lt;fieldset&gt; &lt;legend&gt;Search&lt;/legend&gt; &lt;label&gt;Search SourceForge.net Projects &lt;/label&gt; &lt;select name=&quot;type_of_search&quot;&gt; &lt;option value=&quot;soft&quot; selected=&quot;selected&quot;&gt;Software&lt;/option&gt; &lt;option value=&quot;projectsWithServices&quot;&gt;Marketplace&lt;/option&gt; &lt;/select&gt; &lt;input id=&quot;searchbox&quot; name=&quot;words&quot; tabindex=&quot;1&quot; type=&quot;text&quot; /&gt;&lt;input value=&quot;Search&quot; id=&quot;searchsubmit&quot; tabindex=&quot;0&quot; type=&quot;submit&quot; /&gt;&nbsp;&nbsp;<a href="http://sourceforge.net/search/" class="advanced">Advanced</a> &lt;/fieldset&gt; &lt;/form&gt; </div> <div id="frame" class="wiki_export_theme"> &lt;!-- begin content --&gt; <div id="innerframe" class="project"> <div id="fad1p">&nbsp;</div> <ul id="breadcrumb"> <li class="begin"><a href="http://sourceforge.net/">SF.net</a></li> <li><a href="http://sourceforge.net/softwaremap/">Projects</a></li> <li><a href="http://sourceforge.net/projects/nhcontrib/">nhcontrib</a></li> <li class="selected"><a href="/">Wiki</a></li> </ul> <a name="projectnav"></a> <div class="topnav"> <h2><span>NHibernate Contrib</span></h2> &lt;form action=&quot;/search/&quot; method=&quot;get&quot; class=&quot;projectsearch&quot;&gt; &lt;input name=&quot;type_of_search&quot; value=&quot;pervasive&quot; type=&quot;hidden&quot; /&gt; &lt;input name=&quot;group_id&quot; value=&quot;216446&quot; type=&quot;hidden&quot; /&gt; &lt;label&gt;Search Project &lt;/label&gt;&lt;input value=&quot; Project&quot; class=&quot;searchword passive&quot; id=&quot;projectsearchbox&quot; name=&quot;words&quot; tabindex=&quot;4&quot; onfocus=&quot;this.className='active'; if(this.value==' Project')this.value='';&quot; onblur=&quot;if(this.value=='')this.value=' Project';this.className='passive';&quot; type=&quot;text&quot; /&gt; &lt;input value=&quot;Search&quot; class=&quot;submit&quot; tabindex=&quot;5&quot; type=&quot;submit&quot; /&gt; <a href="http://sourceforge.net/search/?group_id=216446&amp;type_of_search=pervasive" class="advanced">Advanced</a> &lt;/form&gt; <div class="firstwave"> <ul class="nav"> <li><a href="http://sourceforge.net/projects/nhcontrib/">Summary</a> <ul> <li><a href="http://www.nhforge.org">Web Site</a></li> <li><a href="http://sourceforge.net/project/screenshots.php?group_id=216446">Screenshots</a></li> <li><a href="http://sourceforge.net/news/?group_id=216446">News</a></li> <li><a href="http://sourceforge.net/project/stats/?group_id=216446&amp;ugn=nhcontrib">Statistics</a></li> </ul> </li> <li class="advanced"><a href="http://sourceforge.net/mail/?group_id=216446">Mailing&nbsp;Lists</a> <ul> <li><a href="http://sourceforge.net/mailarchive/forum.php?forum_name=nhcontrib-commits">nhcontrib-commits</a></li> <li class="tools"><a href="http://sourceforge.net/search/?group_id=216446&amp;type_of_search=mlists">Search</a></li> </ul> </li> <li class="advanced"><a href="http://sourceforge.net/svn/?group_id=216446">Code</a> <ul> <li><a href="http://sourceforge.net/svn/?group_id=216446">SVN</a></li> <li><a href="http://nhcontrib.svn.sourceforge.net/viewvc/nhcontrib/">SVN Browse</a></li> <li><a href="http://sourceforge.net/project/stats/detail.php?group_id=216446&amp;ugn=nhcontrib&amp;type=svn">SVN Statistics</a></li> </ul> </li> <li class="advanced"><a href="http://sourceforge.net/services/project_services.php?project_id=216446">Services</a> <ul> <li><a href="http://sourceforge.net/services/project_services.php?project_id=216446">Get Services</a></li> </ul> </li> <li><a href="http://sourceforge.net/project/showfiles.php?group_id=216446">Download</a> <ul> <li><a href="http://sourceforge.net/project/showfiles.php?group_id=216446">Browse All Files</a></li> <li class="tools"><a href="http://sourceforge.net/project/stats/detail.php?group_id=216446&amp;ugn=nhcontrib&amp;type=prdownload">Statistics</a></li> <li><a href="http://sourceforge.net/search/?group_id=216446&amp;type_of_search=files">Search</a></li> </ul> </li> <li class="advanced selected"><a href="http://nhcontrib.wiki.sourceforge.net/">Wiki</a> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/">Wiki Home</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/page">Create Page</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/pagelist">List Pages</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/changes">Recent Changes</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/filelist">List and Upload Files</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/createtemplate">Manage Templates</a></li> <li class="tools"><a href="http://nhcontrib.wiki.sourceforge.net/space/stats">Statistics</a></li> </ul> </li> </ul> </div> <div id="thirdwave"></div> &lt;small class=&quot;options&quot;&gt; <a href="http://sourceforge.net/project/stats/?group_id=216446&amp;ugn=nhcontrib" class="sitestats" title="Project Stats - Activity: 99.67%">Stats</a> <a href="http://sourceforge.net/export/rss2_project.php?group_id=216446" class="rss">RSS</a> &lt;/small&gt; <br /> </div> </div> &lt;!-- begin right column --&gt; <a name="content"></a> <div id="WikispacesContent"> <span style="display:none;"> <div class="WikiHeaderNav WikiElement"><b>guest</b> &middot; <a href="http://sourceforge.net/account/newuser_emailverify.php?goto=:nhcontrib:%2FBurrowIntroduction" rel="nofollow">Join</a> &middot; <a href="http://www.wiki.sourceforge.net/help+index" rel="nofollow">Help</a> &middot; <a href="https://sourceforge.net/account/login.php?goto=:nhcontrib:%2FBurrowIntroduction" rel="nofollow">Sign In</a> &middot; <a href="http://www.wiki.sourceforge.net"><img src="/i/little_logo.gif" alt="wikispaces" height="20" width="83" /></a></div> </span> <div> <div id="leftcolumn"> <h3 class="titlebar"><img src="/i/c.gif" height="17" width="1" alt="" />Wiki&nbsp;Navigation</h3> <div class="menu"> <ul class="WikiActions WikiElement" style="font-size:90%;"> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/changes"><img src="/i/icon_16_date.gif" height="16" width="16" alt="" /></a><a href="http://nhcontrib.wiki.sourceforge.net/space/changes">Recent Changes</a></li> <li><a href="http://nhcontrib.wiki.sourceforge.net/space/about"><img src="/i/icon_16_gear.gif" height="16" width="16" alt="" /></a><a href="http://nhcontrib.wiki.sourceforge.net/space/about">Manage Space</a></li> </ul> </div> &lt;!-- google_ad_section_start --&gt; <div class="WikiCustomNav WikiElement wiki"><a class="wiki_link" href="/">Home</a><br /> <ul> <li><a class="wiki_link" href="/BurrowHome">Burrow</a> <ul> <li><a class="wiki_link" href="/BurrowIntroduction">Introduction</a></li> <li><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></li> <li><a class="wiki_link" href="/BurrowConversationExplained">Conversation</a></li> <li><a class="wiki_link" href="/BurrowStatefulFields">StatefulField</a></li> <li><a class="wiki_link" href="/BurrowFAQ">FAQ</a></li> <li><a class="wiki_link" href="/Example">Example</a></li> </ul> </li> </ul> </div> &lt;!-- google_ad_section_end --&gt; </div> <div id="rightcolumn"> <h3 class="titlebar">&lt;!-- google_ad_section_start --&gt;<span class="WikiPageMenuTitle WikiElement">BurrowIntroduction</span>&lt;!-- google_ad_section_end --&gt;</h3> <div style="margin-left:28px;"> <div class="WikiPageMenuEntries WikiElement"> <ul> <li class="WikiPageMenuEntryOn"><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">page</a></li> <li class="WikiPageMenuEntryOff"><a href="http://nhcontrib.wiki.sourceforge.net/message/list/BurrowIntroduction">discussion</a></li> <li class="WikiPageMenuEntryOff"><a href="http://nhcontrib.wiki.sourceforge.net/page/history/BurrowIntroduction">history</a></li> <li class="WikiPageMenuEntryOff"><a href="http://nhcontrib.wiki.sourceforge.net/page/notify/BurrowIntroduction">notify me</a></li> </ul> </div> <div class="WikiPageMenuEntries WikiElement"> <ul> <li class="WikiPageMenuEntryOff"><a href="/page/links/BurrowIntroduction">backlinks</a></li> </ul> </div> </div> <div style="float:right;"> <span class="WikiPageMenuEditButtonNoPermission"><span>Protected</span></span></div> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- #contentEditButton { display: none; } --&gt;&lt;/style&gt; <div class="contentBox"> <div class="innerContentBox"> <div id="WikiAdMargin"> &lt;link rel=&quot;microsummary&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/page/microsummary/BurrowIntroduction/edits&quot; /&gt; &lt;link rel=&quot;microsummary&quot; href=&quot;http://nhcontrib.wiki.sourceforge.net/page/microsummary/BurrowIntroduction/messages&quot; /&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var baseUrl = 'http://www.wiki.sourceforge.net/_/2007033001'; function editorEnable() { if (navigator.userAgent.toLowerCase().indexOf('safari') + 1 || navigator.userAgent.toLowerCase().indexOf('opera') + 1) { document.location = '/page/edit/' + encodeURIComponent(pagename) + '?texteditor=1'; exit(); } try { // Seems to work if we put it before an xmlHTTPRequest, it loads in time dynamicLoadJavascript(baseUrl + '/s/autosave.js'); dynamicLoadJavascript(baseUrl + '/s/windows_js_0.96/javascripts/window.js'); dynamicLoadJavascript(baseUrl + '/s/windows_js_0.96/javascripts/effects.js'); dynamicLoadCss(baseUrl + '/s/windows_js_0.96/themes/default.css'); dynamicLoadCss(baseUrl + '/s/windows_js_0.96/themes/wikispaces.css'); var url = '/page/dump/' + encodeURIComponent(pagename) + '?format=Wikispaces2'; new Ajax.Request(url, {asynchronous:true, method:'get', onSuccess:editorEnableCallback, onFailure:redirectToEditPage, onException:redirectToEditPage}); } catch (e) { document.location = '/page/edit/' + encodeURIComponent(pagename); } } function redirectToEditPage(request, header) { document.location = '/page/edit/' + encodeURIComponent(pagename); } function editorEnableCallback(request, headers) { var xml = request.responseXML; display('editor_wrap', 'block', 'block'); // Load the fetched XML and set it up for the editor if (loadXMLData(xml) &amp;&amp; customEditorStart('WikispacesEditorContentHidden')) { display('WikiTags', 'none', 'none'); display('content_view', 'none', 'none'); display('WikiAds', 'none', 'none'); o = document.getElementById('WikiAdMargin'); if (o) o.style.marginRight = '0px'; return true; } // Something failed, and we're in a callback, so we have to change the page location to the edit page like this redirectToEditPage(null, null); } function loadXMLData(xml) { var wikiPageData = xml.getElementsByTagName('dump')[0].getElementsByTagName('content')[0].firstChild.nodeValue; version = xml.getElementsByTagName('dump')[0].getElementsByTagName('version')[0].firstChild.nodeValue; if (!wikiPageData &amp;&amp; version != 0) { return false; } if (xml.getElementsByTagName('dump')[0].getElementsByTagName('autosave').length &gt; 0) { var autosaveRoot = xml.getElementsByTagName(&#39;dump&#39;)[0].getElementsByTagName(&#39;autosave&#39;)[0]; var autosaveContent = autosaveRoot.getElementsByTagName(&#39;autosaveContent&#39;)[0].firstChild.nodeValue; var autosaveDate = autosaveRoot.getElementsByTagName(&#39;autosaveDate&#39;)[0].firstChild.nodeValue; autosaveVersion = autosaveRoot.getElementsByTagName(&#39;autosaveVersion&#39;)[0].firstChild.nodeValue; document.getElementById(&#39;autosavePrompt&#39;).innerHTML = &#39;<h1>Draft Recovered</h1>We have recovered an unsaved draft of this page, created &#39; + autosaveDate + &#39;.<br /><br />&#39; + (autosaveVersion != version ? &#39;However, another person has edited this page since your last draft. If you continue, their changes will be overwritten. To view these changes, <a href="/page/diff/&#39;%20+%20encodeURIComponent(pagename)%20+%20&#39;?v1=&#39;%20+%20autosaveVersion%20+%20&#39;&amp;v2=&#39;%20+%20version%20+%20&#39;">click here</a>.<br />&#39; : &#39;&#39;); document.getElementById(&#39;autosaveContent&#39;).innerHTML = autosaveContent; if (typeof(Dialog) != &#39;undefined&#39;) { showAutosavePopup(); } else { return false; } } else { //Only start the autosave loop after the modal autosave popup has closed or if it wasn&#39;t displayed setTimeout(&quot;autosaveLoop()&quot;, 1000); } // Store loaded page data in the same place that the edit page would have it document.getElementById(&#39;WikispacesEditorContentHidden&#39;).innerHTML = wikiPageData; return true; } // --&gt;&lt;/script&gt; &lt;!-- The wiki div is styled in the customizable stylesheet --&gt; <div class="wiki" id="content_view"> <div id="autosaveContent" style="display:none;"></div> <div id="autosavePrompt" style="display:none;"></div> <div id="contentEditButton"> <img alt="Protected" title="Only members of this space may edit pages" src="/i/edit_nopermission.png" style="float:right;margin:0 0 .5em .5em;" height="37" width="128" /> </div> &lt;!-- google_ad_section_start --&gt; <h2 id="tocBurrowIntroduction0"><b>Why Is Burrow Needed?</b></h2> Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework.<br /> Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates.<br /> <br /> The core concept of Burrow is <a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation</a>, which was inspired by the Conversation concept in <a class="wiki_link_ext" href="http://www.jboss.com/products/seam" rel="nofollow">JBoss Seam </a>. Conversation is designed to represent a stateful business conversation between end-user and system. Burrow manages NH session around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of the conversation.<br /> For business transactions that can be taken care of in one http request response round trip, for example, modifying the customer information, Burrow takes care of the conversation transparently, which means that your code does not need to be aware of Burrow conversation. By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request.<br /> <br /> OpenSessionInView pattern isn&#39;t hard to implement, but the real power Burrow provides is that Burrow conversation can span over multiple http requests, in another sentence, Burrow Conversation allows end user to have a stateful business conversation with the system that spans over multiple http request and response. For example the checkout process is a typical business transaction that can span over multiple request/response dialogues - user needs to enter shipping information, billing information and confirm the order information. Through conversation, Burrow can also make sure that such long business transaction is atomic and isolated by applying atomic transaction strategy. More importantly, like in Seam, one user can have multiple Burrow conversations with the system simultaneously.<br /> For more information about Burrow Conversation, <a class="wiki_link" href="/BurrowConversationExplained">click here</a>.<br /> <br /> <h2 id="tocBurrowIntroduction1">Main Features of Burrow</h2> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction</li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time</li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception.</li> <li><b>Multiple databases support</b>. multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases.</li> </ul> <br /> <h2 id="tocBurrowIntroduction2"><b>A Simple Example about Long Conversation</b></h2> To demonstrate Burrow, we used the basic example from the well-known article &quot;<a class="wiki_link_ext" href="http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx%20" rel="nofollow">NHibernate Best Practices with ASP.NET</a>&quot; from CodeProject.com. We have two versions of modifications of it:<br /> <ul> <li>BasicCore example - it only uses the core Burrow function - session management. This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowCore</li> <li>BasicAppBlock example - it uses not only the core part but also some other optional classes from Burrow.WebUtil and Burrow.AppBlock to significantly simplify code . This example can be found in NHContribRoot\Examples\NHBestPracticesWAspNet\BasicSampleWithBurrowAppBlock</li> </ul> <br /> Most of the code in BasicCore example is the same as the original basic sample to demonstrate that Burrow can be used with any design and architecture. We added a PlaceOrder.aspx to demonstrate what Burrow can enable - business transaction that spans over multiple requests. This page is like a checkout page, but tweaked for demo purpose. The steps are simple as the point here is to demonstrate the multiple steps.<br /> <b>PlaceOrder.aspx</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- --&gt;&lt;/style&gt; <pre> &lt;asp:PlaceHolder ID=&quot;phSelectCustomer&quot; runat=&quot;server&quot; Visible=&quot;true&quot;&gt; Select a customer who wants to place an order (will be the OrderBy)&lt;br /&gt; &lt;asp:DropDownList ID=&quot;ddlCustomers&quot; runat=&quot;server&quot; DataTextField=&quot;ContactName&quot; DataValueField=&quot;ID&quot;&gt; &lt;/asp:DropDownList&gt; &lt;asp:Button ID=&quot;btnSelectCustomer&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;Step1&quot; /&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phEnterShipToName&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt; Please enter your ship to information: &lt;asp:TextBox ID=&quot;tbShipToName&quot; runat=&quot;server&quot;&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID=&quot;btnEnterShipTo&quot; runat=&quot;server&quot; Text=&quot;Next&quot; OnClick=&quot;btnStep2&quot; /&gt;&lt;br /&gt; &lt;asp:Button ID=&quot;btnCancel&quot; OnClick=&quot;Cancel&quot; runat=&quot;server&quot; Text=&quot;cancel&quot;&gt;&lt;/asp:Button&gt; &lt;/asp:PlaceHolder&gt; &lt;asp:PlaceHolder ID=&quot;phConfirm&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;Customer: &lt;asp:Literal ID=&quot;lCustomer&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; Ship to: &lt;asp:Literal ID=&quot;lShipTo&quot; runat=&quot;server&quot;&gt;&lt;/asp:Literal&gt; &lt;br /&gt; &lt;asp:Button ID=&quot;btnConfirm&quot; runat=&quot;server&quot; Text=&quot;Confirm&quot; OnClick=&quot;Finish&quot; /&gt; &lt;/asp:PlaceHolder&gt;</pre> <br /> <b>PlaceOrder.aspx.cs</b><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .text .imp {font-weight: bold; color: red;} --&gt;&lt;/style&gt; <pre class="text">public partial class PlaceOrder : Page { private IDaoFactory daoFactory = new NHibernateDaoFactory(); private BurrowFramework bf = new BurrowFramework(); &nbsp; /// &lt;summary&gt; /// Store the placing order in the Conversation.Items so that it has the same life span as the Conversation /// &lt;/summary&gt; public Order placingOrder { get { return (Order) bf.CurrentConversation.Items[&quot;placingOrder&quot;]; } set { bf.CurrentConversation.Items[&quot;placingOrder&quot;] = value; } } &nbsp; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ddlCustomers.DataSource = daoFactory.GetCustomerDao().GetAll(); ddlCustomers.DataBind(); } } &nbsp; protected void Step1(object sender, EventArgs e) { //start an atomic Conversation that span over postbacks bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction); Customer selectedCustomer = daoFactory.GetCustomerDao().GetById(ddlCustomers.SelectedValue, false); placingOrder = new Order(selectedCustomer) ; phSelectCustomer.Visible = false; phEnterShipToName.Visible = true; } &nbsp; protected void btnStep2(object sender, EventArgs e) { placingOrder.ShipToName = tbShipToName.Text; phEnterShipToName.Visible = false; phConfirm.Visible = true; lCustomer.Text = placingOrder.OrderedBy.ToString(); lShipTo.Text = placingOrder.ShipToName; } &nbsp; protected void Cancel(object sender, EventArgs e) { bf.CurrentConversation.GiveUp(); // give up the current spanning conversation phEnterShipToName.Visible = false; StartOver(); } &nbsp; private void StartOver() { phSelectCustomer.Visible = true; } &nbsp; protected void Finish(object sender, EventArgs e) { placingOrder.OrderDate = DateTime.Now; daoFactory.GetOrderDao().Save(placingOrder); bf.CurrentConversation.FinishSpan(); //finish up the current spanning conversation placingOrder = null; //reset the placing order to null after conversation is done is a good practice phConfirm.Visible = false; StartOver(); } }</pre> <br /> In step 1, &quot;bf.CurrentConversation.SpanWithPostBacks();&quot; is the line to let the system know that the current conversation needs to span after the end of the current request. Without this line, the current conversation will closed at the end of the request (as in OpenSessionPerView mode). Then the code created an order entity and store it into the bf.CurrentConversation.Items[&quot;placingOrder&quot;]. IConversation.Items is a data container through which you can store the data into the current conversation so that the data will have the same life cycle as the conversation. Step2 simple modifies the shipToName property of the placingOrder. The finish step finally persists the order and calls bf.CurrentConversation.FinishSpan(); then Burrow will commit and close this multi-request conversation at the end of this request.<br /> <br /> For more information about NHibernate.Burrow, here is a guide to the pages of this wiki site:<br /> <b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework.<br /> <b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail in long conversation.<br /> <b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages<br /> <b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is.&lt;!-- google_ad_section_end --&gt; </div> &lt;!-- /wiki --&gt; &lt;script src=&quot;http://www.wiki.sourceforge.net/_/2007033001/s/rte/richtext.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;http://www.wiki.sourceforge.net/_/2007033001/s/scriptaculous/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;http://www.wiki.sourceforge.net/_/2007033001/s/image_edit.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; <div id="editor_wrap"> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- var editorId = 'WikispacesEditorContent'; var mode = 'visual'; var siteDomainShort = 'wiki.sourceforge.net'; var pagename = 'BurrowIntroduction'; var version = '185299'; var editorConfirmDeparture = true; var editorSaving = false; var autosaveEnabled = false; var autosaveVersion = '185299'; var insertImageInEditor = insertImageInVisualEditor; var editorSubmit = visualEditorSubmit; var insertInEditor = insertHTML var stylesheetUrl = 'http://www.wiki.sourceforge.net/stylesheet/view/www'; initRTE('/s/rte/images/', '/s/rte/', ''); writeToolbar(editorId); // --&gt;&lt;/script&gt; &lt;form action=&quot;http://nhcontrib.wiki.sourceforge.net/page/edit/BurrowIntroduction&quot; method=&quot;post&quot; name=&quot;rte&quot; onsubmit=&quot;return editorSubmit();&quot; class=&quot;form&quot; style=&quot;background-color: #FFF; padding: 0; margin: 0; border:0; display:inline;&quot;&gt; <div id="editor" style="width:99%;min-width:99%;"></div> <div id="WikispacesEditorContentHidden" style="display:none;"></div> &lt;!-- inputs have to come after divs, even though they are hidden, otherwise IE puts extra spaces --&gt; &lt;input name=&quot;changeDetected&quot; type=&quot;hidden&quot; /&gt; &lt;input name=&quot;version&quot; value=&quot;185299&quot; type=&quot;hidden&quot; /&gt; &lt;input name=&quot;mode&quot; value=&quot;visual&quot; type=&quot;hidden&quot; /&gt; <h3><i>Optional:</i> a note about this edit for the page history log</h3> &lt;input name=&quot;comment&quot; size=&quot;100&quot; class=&quot;WikispacesEditorInput&quot; type=&quot;text&quot; /&gt; <div style="display:none;" id="hierarchy"> </div> &lt;!-- bottom toolbar --&gt; <table style="padding:8px 0 4px 0;" align="right"> &lt;tbody&gt; <tr> <td> <span id="autosaveStatus">&nbsp;</span> &lt;input name=&quot;switch_to_plain&quot; value=&quot;Text Editor&quot; onclick=&quot;editorConfirmDeparture = false;&quot; type=&quot;submit&quot; /&gt; &lt;input name=&quot;preview&quot; value=&quot;Preview&quot; onclick=&quot;editorConfirmDeparture = false;&quot; type=&quot;submit&quot; /&gt; &lt;input name=&quot;update&quot; value=&quot;Save&quot; style=&quot;font-weight: bold;&quot; onclick=&quot;editorConfirmDeparture = false; editorSaving = true;&quot; type=&quot;submit&quot; /&gt; <a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Cancel</a> </td> </tr> &lt;/tbody&gt; </table> &lt;/form&gt; &lt;!-- stuff that is not displayed (popup windows, session iframe, javascript data --&gt; <div id="imageDiv" style="display:none;padding:5px;"> <span style="font-size:0.8em;">Double click an image or file to insert it into the page.</span><br /> &lt;form action=&quot;#&quot; name=&quot;listModeForm&quot; method=&quot;post&quot; style=&quot;display: inline;&quot;&gt; <span style="font-size:0.8em;">Show: &lt;input id=&quot;listModeAll&quot; name=&quot;listMode&quot; value=&quot;all&quot; checked=&quot;checked&quot; onclick=&quot;setListMode('all');&quot; type=&quot;radio&quot; /&gt;&lt;label for=&quot;listModeAll&quot;&gt;All&lt;/label&gt; &lt;input id=&quot;listModeImages&quot; name=&quot;listMode&quot; value=&quot;images&quot; onclick=&quot;setListMode('images');&quot; type=&quot;radio&quot; /&gt;&lt;label for=&quot;listModeImages&quot;&gt;Images Only&lt;/label&gt; &lt;input id=&quot;listModeFiles&quot; name=&quot;listMode&quot; value=&quot;files&quot; onclick=&quot;setListMode('files');&quot; type=&quot;radio&quot; /&gt;&lt;label for=&quot;listModeFiles&quot;&gt;Files Only&lt;/label&gt;<br /> </span> &lt;/form&gt; <span id="imagePages"> Page: </span><br /> <span id="imageJumpLinks" style="font-size:.7em;"> Jump: </span><br /> <table id="imageTable" class="imageTable"> &lt;tbody id=&quot;imageSection&quot;&gt; &lt;/tbody&gt; &lt;tbody id=&quot;otherSection&quot;&gt; <tr id="uploadRow"> <td colspan="5"> <h2 style="font-size:1.0em;margin:0px;">Upload New File <img id="uploadSpinner" src="/i/c.gif" alt="notUploading" height="18" width="18" /></h2> You must sign in to upload files. </td> </tr> &lt;/tbody&gt; </table> <hr /> <h2 style="font-size:0.9em;margin:0px;">External Image URL</h2> <span style="font-size:0.8em;">Load an external image, then double click the image to insert it into the page.</span><br /> <div id="externalImage" style="text-align:center;"></div> &lt;form enctype=&quot;multipart/form-data&quot; action=&quot;#&quot; method=&quot;post&quot; onsubmit=&quot;showExternalImage(); return false;&quot; style=&quot;display: inline;&quot;&gt; &lt;input id=&quot;externalImageUrl&quot; name=&quot;url&quot; size=&quot;35&quot; type=&quot;text&quot; /&gt;<br /> &lt;input value=&quot;Load Image&quot; type=&quot;submit&quot; /&gt;<br /> &lt;/form&gt; </div> <div id="concurrentEditor" style="display:none;"> <h1 id="concurrentEditor_otherEditor_heading">Other users editing this page</h1> <ul id="concurrentEditor_otherEditors"> <li id="concurrentEditor_noEditors">None</li> </ul> <h1 id="concurrentEditor_savedVersion_heading" style="display:none;">Changes since you started editing</h1> <ul id="concurrentEditor_savedVersions"> </ul> <ul> <li id="concurrentEditor_savedVersion_viewChanges" style="display:none;"></li> </ul> </div> <div id="codePopupContents" style="display:none;padding:5px;"> &lt;form action=&quot;#&quot; name=&quot;codeForm&quot; method=&quot;post&quot; style=&quot;display: inline;&quot; onsubmit=&quot;return false;&quot;&gt; Format: &lt;select name=&quot;format&quot;&gt; &lt;option value=&quot;text&quot;&gt;Plain Text&lt;/option&gt; &lt;option&gt;&lt;/option&gt; &lt;option value=&quot;actionscript&quot;&gt;Actionscript&lt;/option&gt; &lt;option value=&quot;ada&quot;&gt;Ada&lt;/option&gt; &lt;option value=&quot;apache&quot;&gt;Apache configuration file&lt;/option&gt; &lt;option value=&quot;applescript&quot;&gt;Applescript&lt;/option&gt; &lt;option value=&quot;asm&quot;&gt;x86 Assembler&lt;/option&gt; &lt;option value=&quot;asp&quot;&gt;Active Server Pages&lt;/option&gt; &lt;option value=&quot;autoit&quot;&gt;AutoIt Window automation script&lt;/option&gt; &lt;option value=&quot;bash&quot;&gt;Bourne Again Shell&lt;/option&gt; &lt;option value=&quot;blitzbasic&quot;&gt;Blitz Basic&lt;/option&gt; &lt;option value=&quot;bnf&quot;&gt;BNF: Backus-Naur form&lt;/option&gt; &lt;option value=&quot;c&quot;&gt;C&lt;/option&gt; &lt;option value=&quot;cfdg&quot;&gt;Context-Free Design Grammar&lt;/option&gt; &lt;option value=&quot;cfm&quot;&gt;Coldfusion&lt;/option&gt; &lt;option value=&quot;cpp&quot;&gt;C++&lt;/option&gt; &lt;option value=&quot;csharp&quot;&gt;C#&lt;/option&gt; &lt;option value=&quot;css&quot;&gt;Cascading Style Sheets&lt;/option&gt; &lt;option value=&quot;delphi&quot;&gt;Delphi Object Pascal&lt;/option&gt; &lt;option value=&quot;diff&quot;&gt;Diff&lt;/option&gt; &lt;option value=&quot;div&quot;&gt;Div&lt;/option&gt; &lt;option value=&quot;dos&quot;&gt;DOS&lt;/option&gt; &lt;option value=&quot;d&quot;&gt;D programming language&lt;/option&gt; &lt;option value=&quot;eiffel&quot;&gt;Eiffel&lt;/option&gt; &lt;option value=&quot;freebasic&quot;&gt;Free Basic&lt;/option&gt; &lt;option value=&quot;fortran&quot;&gt;Fortran&lt;/option&gt; &lt;option value=&quot;gml&quot;&gt;Game Maker Language&lt;/option&gt; &lt;option value=&quot;groovy&quot;&gt;Groovy&lt;/option&gt; &lt;option value=&quot;html4strict&quot;&gt;HTML&lt;/option&gt; &lt;option value=&quot;idl&quot;&gt;Uno IDL&lt;/option&gt; &lt;option value=&quot;ini&quot;&gt;INJ&lt;/option&gt; &lt;option value=&quot;inno&quot;&gt;Inno Script Object Pascal&lt;/option&gt; &lt;option value=&quot;io&quot;&gt;IO&lt;/option&gt; &lt;option value=&quot;java&quot;&gt;Java&lt;/option&gt; &lt;option value=&quot;java5&quot;&gt;Java, version 5 syntax&lt;/option&gt; &lt;option value=&quot;javascript&quot;&gt;Javascript&lt;/option&gt; &lt;option value=&quot;latex&quot;&gt;LaTeX&lt;/option&gt; &lt;option value=&quot;lisp&quot;&gt;Lisp&lt;/option&gt; &lt;option value=&quot;matlab&quot;&gt;Matlab&lt;/option&gt; &lt;option value=&quot;mirc&quot;&gt;mIRC&lt;/option&gt; &lt;option value=&quot;mysql&quot;&gt;MySQL SQL&lt;/option&gt; &lt;option value=&quot;oracle8&quot;&gt;Oracle SQL&lt;/option&gt; &lt;option value=&quot;ocaml&quot;&gt;Objective Caml&lt;/option&gt; &lt;option value=&quot;pascal&quot;&gt;Pascal&lt;/option&gt; &lt;option value=&quot;perl&quot;&gt;PERL&lt;/option&gt; &lt;option value=&quot;php&quot;&gt;PHP&lt;/option&gt; &lt;option value=&quot;python&quot;&gt;Python&lt;/option&gt; &lt;option value=&quot;qbasic&quot;&gt;QBasic&lt;/option&gt; &lt;option value=&quot;reg&quot;&gt;Microsoft Registry&lt;/option&gt; &lt;option value=&quot;robots&quot;&gt;robots.txt&lt;/option&gt; &lt;option value=&quot;ruby&quot;&gt;Ruby&lt;/option&gt; &lt;option value=&quot;sas&quot;&gt;SAS&lt;/option&gt; &lt;option value=&quot;scheme&quot;&gt;Scheme&lt;/option&gt; &lt;option value=&quot;sdlbasic&quot;&gt;sdlbasic&lt;/option&gt; &lt;option value=&quot;smalltalk&quot;&gt;Smalltalk&lt;/option&gt; &lt;option value=&quot;smarty&quot;&gt;Smarty PHP template language&lt;/option&gt; &lt;option value=&quot;sql&quot;&gt;SQL&lt;/option&gt; &lt;option value=&quot;tcl&quot;&gt;TCL&lt;/option&gt; &lt;option value=&quot;thinbasic&quot;&gt;Thinbasic&lt;/option&gt; &lt;option value=&quot;tsql&quot;&gt;Transact-SQL&lt;/option&gt; &lt;option value=&quot;vb&quot;&gt;Visual Basic&lt;/option&gt; &lt;option value=&quot;vbnet&quot;&gt;Visual Basic .NET&lt;/option&gt; &lt;option value=&quot;vhdl&quot;&gt;VHSICADL, very high speed integrated circuit HDL&lt;/option&gt; &lt;option value=&quot;visualfoxpro&quot;&gt;Visual Fox Pro&lt;/option&gt; &lt;option value=&quot;winbatch&quot;&gt;Windows Batch Scripting&lt;/option&gt; &lt;option value=&quot;xml&quot;&gt;XML&lt;/option&gt; &lt;/select&gt;<br /> <span>Paste the code fragment into the text area</span><br /> &lt;textarea name=&quot;code&quot; cols=&quot;80&quot; rows=&quot;10&quot;&gt;&lt;/textarea&gt;<br /> <div style="text-align:right;">&lt;input value=&quot;Insert Code&quot; onclick=&quot;insertCode();&quot; type=&quot;submit&quot; /&gt; or <a>Cancel</a></div> &lt;/form&gt; </div> &lt;!-- Hidden iframe for restoring session --&gt; <div style="position:absolute;left:0px;top:0px;visibility:hidden;" id="refreshSessionDiv"> &lt;iframe name=&quot;refreshSessionIframe&quot; src=&quot;/i/c.gif&quot; style=&quot;border: 0pt none; width: 0px; height: 0px;&quot;&gt;&lt;/iframe&gt; </div> <div id="imageProperties" style="display:none;padding:5px;"> &lt;form action=&quot;http://nhcontrib.wiki.sourceforge.net/page/edit/BurrowIntroduction&quot; method=&quot;post&quot; name=&quot;imagePropertiesForm&quot; onsubmit=&quot;return false;&quot; style=&quot;display: inline;&quot;&gt; Alignment: &lt;select name=&quot;imageAlign&quot; onchange=&quot;setImageAlignment(this.value);&quot;&gt; &lt;option&gt;None&lt;/option&gt; &lt;option value=&quot;left&quot;&gt;Left&lt;/option&gt; &lt;option value=&quot;center&quot;&gt;Center&lt;/option&gt; &lt;option value=&quot;right&quot;&gt;Right&lt;/option&gt; &lt;/select&gt; &lt;/form&gt;<br /> Link: <span id="imageLink"></span><br /> <span id="imageLinkControlsActive" style="display:none;"> <a>Change Link</a> &middot; <a>Remove Link</a> </span> <span id="imageLinkControlsInactive"> <a>Add Link</a> </span> </div> &lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;&lt;!-- var allFiles = new Array(); // --&gt;&lt;/script&gt; </div> </div> </div> </div> </div> </div> </div> </div> <div id="footer"> <div style="margin:5px 0;font-size:70%;"><a href="http://www.wikispaces.com/t/x/sf"><img src="/i/little_logo.gif" style="vertical-align:middle;" alt="" /></a> <a href="http://www.wikispaces.com/t/x/sf">Wikis by Wikispaces&reg;</a></div> <ul> <li><a href="http://sourceforge.net/docs/about">About SourceForge.net</a></li> <li><a href="http://sourceforge.net/tos/privacy.php">Privacy Statement</a></li> <li><a href="http://sourceforge.net/tos/tos.php">Terms of Use</a></li> <li><a href="http://web.sourceforge.com/media_kit.php">Advertise</a></li> <li><a href="http://sourceforge.net/support/getsupport.php">Get Support</a></li> <li><a href="http://sourceforge.net/supporters.php">Our Supporters</a></li> <li><a href="http://sourceforge.net/subscriptions.php">Subscribe</a></li> <li><a href="http://sourceforge.net/export/rss2_sfnews.php?group_id=1&amp;rss_fulltext=1">RSS</a></li> </ul> <p> &copy;Copyright 1999-2008 - <a href="http://sourceforge.com" title="Network which provides and promotes Open Source software downloads, development, discussion and news.">SourceForge</a>, Inc., All Rights Reserved </p> <ul class="ostgnavbar"> <li class="begin"><a href="http://sourceforge.com">SourceForge</a></li> <li><a href="http://thinkgeek.com">ThinkGeek</a></li> <li><a href="http://slashdot.org">Slashdot</a></li> <li><a href="http://linux.com">Linux.com</a></li> <li><a href="http://freshmeat.net">freshmeat</a></li> <li><a href="http://ad.doubleclick.net/clk;201022080;26352883;r?http://seeker.dice.com/jobsearch/genthree/index.jsp">Jobs</a></li> </ul> </div> &lt;!-- Ad calls and positioning --&gt; <div id="adbatch" class="wiki_export_theme"> <div id="fad1"> <div> <div> &lt;!-- DoubleClick Ad Tag --&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- //&lt;![CDATA[ if(immersion_adcode == &quot;&quot;){ var adspot = &quot;wiki_p1_leader&quot;; if(adid !=&quot;&quot;) adspot+= &quot;;comp=&quot; +adid +&quot;&quot;; document.write('&lt;script src=&quot;http://ad.doubleclick.net/adj/ostg.sourceforge/'+adspot+';pg=/export/theme.php;psrch=0;logged_in=0;tile='+dfp_tile+';tpc=alexandria;tpc=os_groups;tpc=independent;tpc=php;tpc=dynamic;tpc=www;tpc=internet;ord='+dfp_ord+'?&quot; mce_src=&quot;http://ad.doubleclick.net/adj/ostg.sourceforge/'+adspot+';pg=/export/theme.php;psrch=0;logged_in=0;tile='+dfp_tile+';tpc=alexandria;tpc=os_groups;tpc=independent;tpc=php;tpc=dynamic;tpc=www;tpc=internet;ord='+dfp_ord+'&quot; type=&quot;text/javascript&quot;&gt;&lt;\/script&gt;&#39;); dfp_tile++; } // --&gt;&lt;/script&gt; &lt;!-- End DoubleClick Ad Tag --&gt; </div> </div> </div> </div> <p> &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- pageTracker._trackPageview(); external_pageTracker._trackPageview(); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- if(typeof(urchinTracker)!='function')document.write('&lt;sc'+'ript src=&quot;'+ 'http'+(document.location.protocol=='https:'?'s://ssl':'://www')+ '.google-analytics.com/urchin.js'+'&quot;&gt;&lt;/sc'+'ript&gt;&#39;); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- _uacct = &quot;&quot;; urchinTracker(&quot;//goal&quot;); // --&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- jQuery(&quot;.WikiPageMenuEntries ul li a&quot;).not(&quot;this:last&quot;).after(&quot;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;); if (/\/page\/links\//i.test(document.location)) { jQuery(&quot;.WikiPageMenuEntries ul li&quot;).removeClass('WikiPageMenuEntryOn'); jQuery(&quot;.WikiPageMenuEntries ul li&quot;).addClass('WikiPageMenuEntryOff'); jQuery(&quot;.WikiPageMenuEntries ul li:last&quot;).addClass('WikiPageMenuEntryOn'); } // --&gt;&lt;/script&gt; &lt;script src=&quot;http://www.google-analytics.com/urchin.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;&lt;!-- _uacct = &quot;UA-32013-21&quot;; _udn = &quot;wiki.sourceforge.net&quot;; urchinTracker(); // --&gt;&lt;/script&gt; </p> &lt;!-- b92jzd1 tt:0.17 wt:0.05 qt:0.12 qc:160 --&gt;BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/4.aspxSun, 07 Sep 2008 17:35:59 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:58kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div class="wiki" id="content_view">&nbsp; <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span> <pre class="xml"> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnit1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <div class="wiki" id="content_view"> For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br />&nbsp;</div> <div class="wiki"> <span class="sc3"><span class="re1">&lt;httpModules<span class="re2">&gt;</span></span></span></div> <pre class="xml"> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/httpModules<span class="re2">&gt;</span></span></span></pre> <br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:<br />&nbsp; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db1hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB2&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db2hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line<br />&nbsp; <pre class="csharp">ISession sess = <span class="kw3">new</span> BurrowFramework<span class="br0">(</span><span class="br0">)</span>.<span class="me1">GetSession</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//Gets the Burrow Managed NHibernate Session</span></pre> Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service<br />&nbsp; <pre class="text">//call this at the beginning (only when not in ASP.NET)<br /> new BurrowFramework.InitWorkSpace();//<br />&nbsp;<br />//call this at the end (only when not in ASP.NET)<br /> new BurrowFramework.CloseWorkSpace();</pre> &nbsp;</div>BurrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/3.aspxSun, 07 Sep 2008 17:34:20 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:57kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div class="wiki" id="content_view">&nbsp; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnit1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <div class="wiki" id="content_view"> For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br />&nbsp;</div> <div class="wiki"> <span class="sc3"><span class="re1">&lt;httpModules<span class="re2">&gt;</span></span></span></div> <pre class="xml"> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/httpModules<span class="re2">&gt;</span></span></span></pre> <br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:<br />&nbsp; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db1hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB2&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db2hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line<br />&nbsp; <pre class="csharp">ISession sess = <span class="kw3">new</span> BurrowFramework<span class="br0">(</span><span class="br0">)</span>.<span class="me1">GetSession</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//Gets the Burrow Managed NHibernate Session</span></pre> Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service<br />&nbsp; <pre class="text">//call this at the beginning (only when not in ASP.NET)<br /> new BurrowFramework.InitWorkSpace();//<br />&nbsp;<br />//call this at the end (only when not in ASP.NET)<br /> new BurrowFramework.CloseWorkSpace();</pre> &nbsp;</div>urrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/2.aspxSun, 07 Sep 2008 17:33:55 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:56kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><b>Configration setting in the Config file:</b></p> <div class="wiki" id="content_view">&nbsp; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnit1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <div class="wiki" id="content_view"> For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br />&nbsp;</div> <div class="wiki"> <span class="sc3"><span class="re1">&lt;httpModules<span class="re2">&gt;</span></span></span></div> <pre class="xml"> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/httpModules<span class="re2">&gt;</span></span></span></pre> <br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:<br />&nbsp; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db1hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB2&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db2hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line<br />&nbsp; <pre class="csharp">ISession sess = <span class="kw3">new</span> BurrowFramework<span class="br0">(</span><span class="br0">)</span>.<span class="me1">GetSession</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//Gets the Burrow Managed NHibernate Session</span></pre> Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service<br />&nbsp; <pre class="text">//call this at the beginning (only when not in ASP.NET)<br /> new BurrowFramework.InitWorkSpace();//<br />&nbsp;<br />//call this at the end (only when not in ASP.NET)<br /> new BurrowFramework.CloseWorkSpace();</pre> &nbsp;</div>urrowGetStartedhttp://www.nhforge.org/wikis/burrow/get-started/revision/1.aspxSun, 07 Sep 2008 17:31:47 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:55kailuowanghttp://www.nhforge.org/wikis/burrow/get-started/comments.aspx<p>This article give you a guide on how to setup NHibernate.Burrow framework for you project.<br /><strong>Configration setting in the Config file:</strong></p> <div class="wiki" id="content_view"> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnit1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> For web.config in ASP.NET applications, you also need to add a HttpModule Setting<br /><br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"><span class="sc3"><span class="re1">&lt;httpModules<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.HttpModule&quot;</span><br /> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.WebUtil.WebUtilHTTPModule,NHibernate.Burrow.WebUtil&quot;</span><span class="re2">/&gt;</span></span><br /><span class="sc3"><span class="re1">&lt;/httpModules<span class="re2">&gt;</span></span></span></pre> <br />You&#39;ll need to maintain your hibernate configuration in the hibernate.cfg.xml (<a class="wiki_link" href="/BurrowCfgSample">click here for a sample</a>) or whatever file name you want. For multiple Databases, you just create a separate hibernate config file for each database and set you config as this:<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .xml .imp {font-weight: bold; color: red;} .xml .coMULTI {color: #808080; font-style: italic;} .xml .es0 {color: #000099; font-weight: bold;} .xml .br0 {color: #66cc66;} .xml .st0 {color: #ff0000;} .xml .nu0 {color: #cc66cc;} .xml .sc0 {color: #00bbdd;} .xml .sc1 {color: #ddbb00;} .xml .sc2 {color: #339933;} .xml .sc3 {color: #009900;} .xml .re0 {color: #000066;} .xml .re1 {font-weight: bold; color: black;} .xml .re2 {font-weight: bold; color: black;} --&gt; &lt;/style&gt; <pre class="xml"> <span class="sc3"><span class="re1">&lt;configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;section</span> <span class="re0">name</span>=<span class="st0">&quot;NHibernate.Burrow&quot;</span> <span class="re0">type</span>=<span class="st0">&quot;NHibernate.Burrow.Configuration.NHibernateBurrowCfgSection&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/configSections<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;NHibernate</span>.Burrow <span class="re2">&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB1&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db1hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">name</span>=<span class="st0">&quot;PersistenceUnitDB2&quot;</span> <span class="re0">nh-config-file</span>=<span class="st0">&quot;db2hibernate.cfg.xml&quot;</span> <span class="re2">/&gt;</span></span><br /> <span class="sc3"><span class="re1">&lt;/persistantUnits<span class="re2">&gt;</span></span></span><br /> <span class="sc3"><span class="re1">&lt;/NHibernate</span>.Burrow<span class="re2">&gt;</span></span></pre> <br />That&#39;s pretty much it. If you only needs OpenSessionPerView, then the only interaction with Burrow is the following line<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .csharp .imp {font-weight: bold; color: red;} .csharp .kw1 {color: #0600FF;} .csharp .kw2 {color: #FF8000; font-weight: bold;} .csharp .kw3 {color: #008000;} .csharp .kw4 {color: #FF0000;} .csharp .kw5 {color: #000000;} .csharp .co1 {color: #008080; font-style: italic;} .csharp .co2 {color: #008080;} .csharp .coMULTI {color: #008080; font-style: italic;} .csharp .es0 {color: #008080; font-weight: bold;} .csharp .br0 {color: #008000;} .csharp .st0 {color: #808080;} .csharp .nu0 {color: #FF0000;} .csharp .me1 {color: #0000FF;} .csharp .me2 {color: #0000FF;} --&gt; &lt;/style&gt; <pre class="csharp">ISession sess = <span class="kw3">new</span> BurrowFramework<span class="br0">(</span><span class="br0">)</span>.<span class="me1">GetSession</span><span class="br0">(</span><span class="br0">)</span>; <span class="co1">//Gets the Burrow Managed NHibernate Session</span></pre> Please note that as the Session is managed by Burrow, you cannot call any method of it that will change the status or the transaction of it.<br />( If you are using Burrow.AppBlock.GenericDAO as your base DAO, then you probably don&#39;t need to explicitly get the managed session at all.)<br /><br />If and only if the application is not in a ASP.NET environment, you will need to call BurrowFramework.InitWorkSpace to initialize the Burrow environment before any work that involves Burrow managed service such as NHibernate Session or Transaction. Also you need to call another method when a workUnit is done and you want to commit it. Afterwards, you will need InitWorkSpace() again before you use Burrow managed service<br /> &lt;style type=&quot;text/css&quot;&gt;&lt;!-- .text .imp {font-weight: bold; color: red;} --&gt; &lt;/style&gt; <pre class="text">//call this at the beginning (only when not in ASP.NET)<br /> new BurrowFramework.InitWorkSpace();//<br />&nbsp;<br />//call this at the end (only when not in ASP.NET)<br /> new BurrowFramework.CloseWorkSpace();</pre> &lt;!-- google_ad_section_end --&gt;</div>Homehttp://www.nhforge.org/wikis/burrow/home/revision/4.aspxSun, 07 Sep 2008 19:02:33 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:88kailuowanghttp://www.nhforge.org/wikis/burrow/home/comments.aspx<p>NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework by providing advanced and smart session/transaction management and other facilitates.<br /><br /><b>Road Map of Burrow Wiki:</b></p> <ul> <li><b><a class="wiki_link" href="/BurrowIntroduction">Introduction</a> -</b> a brief introduction of Burrow </li> <li><b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework. </li> <li><b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail about long conversation. </li> <li><b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> about very useful Burrow.WebUtil attributes that can simplify states persistence for ASP.NET controls and pages </li> <li><b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is. </li> <li><b><a class="wiki_link" href="/Example">Example</a></b> - an example that gives an overall taste of how Burrow simplies ASP.NET/NHibernate development. </li> </ul> <p>&nbsp;</p>Homehttp://www.nhforge.org/wikis/burrow/home/revision/3.aspxSun, 07 Sep 2008 19:02:16 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:69kailuowanghttp://www.nhforge.org/wikis/burrow/home/comments.aspx<p>NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework by providing advanced and smart session/transaction management and other facilitates.<br /><br /><b>Road Map of Burrow Wiki:</b></p> <ul> <li><b><a class="wiki_link" href="/BurrowIntroduction">Introduction</a> -</b> a brief introduction of Burrow </li> <li><b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework. </li> <li><b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail about long conversation. </li> <li><b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> about very useful Burrow.WebUtil attributes that can simplify states persistence for ASP.NET controls and pages </li> <li><b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is. </li> <li><b><a class="wiki_link" href="/Example">Example</a></b> - an example that gives an overall taste of how Burrow simplies ASP.NET/NHibernate development. </li> </ul> <p>&nbsp;</p>BurrowHomehttp://www.nhforge.org/wikis/burrow/home/revision/2.aspxSun, 07 Sep 2008 17:25:17 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:68kailuowanghttp://www.nhforge.org/wikis/burrow/home/comments.aspx<p>NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework by providing advanced and smart session/transaction management and other facilitates.<br /><br /><b>Road Map of Burrow Wiki:</b></p> <ul> <li><b><a class="wiki_link" href="/BurrowIntroduction">Introduction</a> -</b> a brief introduction of Burrow </li> <li><b><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></b> - tells how to setup the Burrow framework. </li> <li><b><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</b> gives more detail about long conversation. </li> <li><b><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</b> about very useful Burrow.WebUtil attributes that can simplify states persistence for ASP.NET controls and pages </li> <li><b><a class="wiki_link" href="/BurrowFAQ">FAQ</a></b> - you know what it is. </li> <li><b><a class="wiki_link" href="/Example">Example</a></b> - an example that gives an overall taste of how Burrow simplies ASP.NET/NHibernate development. </li> </ul> <p>&nbsp;</p>BurrowHomehttp://www.nhforge.org/wikis/burrow/home/revision/1.aspxSun, 07 Sep 2008 17:12:11 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:53kailuowanghttp://www.nhforge.org/wikis/burrow/home/comments.aspx<p>NHibernate.Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework by providing advanced and smart session/transaction management and other facilitates.<br /><br /><strong>Road Map of Burrow Wiki:</strong></p> <ul> <li><strong><a class="wiki_link" href="/BurrowIntroduction">Introduction</a> -</strong> a brief introduction of Burrow </li> <li><strong><a class="wiki_link" href="/BurrowGetStarted">Get Started</a></strong> - tells how to setup the Burrow framework. </li> <li><strong><a class="wiki_link" href="/BurrowConversationExplained">Burrow Conversation Explained</a> -</strong> gives more detail about long conversation. </li> <li><strong><a class="wiki_link" href="/BurrowStatefulFields">StatefulField Attributes</a> -</strong> about very useful Burrow.WebUtil attributes that can simplify states persistence for ASP.NET controls and pages </li> <li><strong><a class="wiki_link" href="/BurrowFAQ">FAQ</a></strong> - you know what it is. </li> <li><strong><a class="wiki_link" href="/Example">Example</a></strong> - an example that gives an overall taste of how Burrow simplies ASP.NET/NHibernate development. </li> </ul> &lt;!-- google_ad_section_end --&gt;FAQhttp://www.nhforge.org/wikis/burrow/faq/revision/6.aspxSun, 07 Sep 2008 21:46:42 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:87kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a class="ExistingPageLink" href="/wikis/burrow/introduction.aspx" title="Click to view the page titled: Introduction">Introduction</a> - a brief introduction. </li> <li><a class="ExistingPageLink" href="/wikis/burrow/get-started.aspx" title="Click to view the page titled: Get Started">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a class="ExistingPageLink" href="/wikis/burrow/conversation-explained.aspx" title="Click to view the page titled: Burrow Conversation Explained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a class="ExistingPageLink" href="/wikis/burrow/stateful-fields.aspx" title="Click to view the page titled: StatefulField Attributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted"></a><a class="ExistingPageLink" href="/wikis/burrow/get-started.aspx" title="Click to view the page titled: Please view Get Started">Please view Get Started</a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted"></a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a class="ExistingPageLink" href="/wikis/burrow/stateful-fields.aspx" title="Click to view the page titled: Click here for detail">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a class="ExistingPageLink" href="/wikis/burrow/conversation-explained.aspx" title="Click to view the page titled: Long Burrow Conversation">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br /><br /><i>&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt;<br /></i></li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>FAQhttp://www.nhforge.org/wikis/burrow/faq/revision/5.aspxSun, 07 Sep 2008 19:58:46 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:86kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Introduction</a> - a brief introduction. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br /><br /><i>&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt;<br /></i></li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p> FAQhttp://www.nhforge.org/wikis/burrow/faq/revision/4.aspxSun, 07 Sep 2008 19:42:26 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:79kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Introduction</a> - a brief introduction. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br /><br /><i>&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt;<br /></i></li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>BurrowFAQhttp://www.nhforge.org/wikis/burrow/faq/revision/3.aspxSun, 07 Sep 2008 18:31:42 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:73kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Introduction</a> - a brief introduction. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br /><br /><i>&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt;<br /></i></li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>BurrowFAQhttp://www.nhforge.org/wikis/burrow/faq/revision/2.aspxSun, 07 Sep 2008 18:30:54 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:67kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Introduction</a> - a brief introduction. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br />&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt; </li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>BurrowFAQhttp://www.nhforge.org/wikis/burrow/faq/revision/1.aspxSun, 07 Sep 2008 18:27:51 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:66kailuowanghttp://www.nhforge.org/wikis/burrow/faq/comments.aspx<ul> <li><b>What is NHibernate.Burrow?</b><br />Burrow is a light weight middleware developed to support .Net applications using NHibernate (maybe also referred as NH in this article) as ORM framework. Using Asp.net with NHibernate could be a challenge because of the fact that NHibernate is a stateful environment while Asp.net is a stateless framework. Burrow can help solve this conflict by providing advanced and smart session/transaction management and other facilitates. </li> </ul> <ul> <li><b>What&#39;s the major benefits offered by NHibernate.Burrow?</b> <ul> <li><b>Burrow Conversation</b> with which you can easily write business transaction </li> <li><b>GenericDAO</b> with which ISession can be seldom touched most of the time </li> <li><b>Stateful field attributes</b> with which marked fields of Asp.net UserControl and Page will be stateful over multiple http requests. It helps UserControls or Pages remember entity without causing lazy load exception. </li> <li><b>Multiple databases support</b> multiple databases becomes easy, you don&#39;t need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multple databases. </li> </ul> </li> <li><b>How do I learn more about NHibernate.Burrow?</b> <ul> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowIntroduction">Introduction</a> - a brief introduction. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a> - tells how to setup the Burrow framework. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation Explained</a> - gives more detail in long conversation. </li> <li><a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">StatefulField Attributes</a> - explains how Burrow.WebUtil attributes can simplify states maintenance for ASP.NET controls and pages </li> </ul> </li> </ul> <ul> <li><b>How do I setup NHibernate.Burrow for my project?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>Why did I get this &quot;cannot find entity with Id x&quot; error with my [EntityField] after I deleted it?</b><br />That&#39;s because by default EntityField is using Session.Load() to load the entity for you. If you delete the entity, you need to reset that field to null, if you want to save this trouble, you can use [EntityFieldDeletionSafe] instead, it&#39;s basically the same except that it&#39;s using Session.Get(). <a href="http://nhcontrib.wiki.sourceforge.net/StatefulFieldAttributes">Click here for detail</a> about EntityFields </li> <li><b>How do I setup multiple databases?</b><br /><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Please view </a><a href="http://nhcontrib.wiki.sourceforge.net/BurrowGetStarted">Get Started</a>. </li> <li><b>How do I store data in HttpSession?</b><br />You might already know that you can not store entity in HttpSession in an OpenSessionPerView mode which is what NHibernate.Burrow is using most of the cases. Instead, you can store entity id in session and load the entity with Id every time you use it. Thanks to NHibernate&#39;s cache, this won&#39;t bring any performance issue to your system. Actually in many cases when you think you need to use HttpSession, what you actually need is <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Long Burrow Conversation</a> . </li> <li><b>How do I do unit test under NHibernate.Burrow?</b><br />To unit test under NHibernate.Burrow&#39;s management you need to write your Setup and TearDown logic as follows.<br /><a href="http://nhcontrib.wiki.sourceforge.net/code">&nbsp;</a><br /></li> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[SetUp]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Initialize() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().InitWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[TearDown]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> Close() {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">new</span> BurrowFramework().CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> <li><br /><a href="http://nhcontrib.wiki.sourceforge.net/code">&nbsp;</a><br />Or you can use NHibernate.Burrow.TestUtil.TestBase as your NUnit unit test base class and override TearDowan() and SetUp() method to add your own TearDown and SetUp logic. </li> <li><b>Is NHibernate.Burrow compatible with Ajax?</b><br />NHibernate.Burrow is compatible with Ajax.Asp.net - the ajax framework provided by Microsoft. </li> <li><b>Why I couldn&#39;t finish a long conversation in an UpdatePanel in an Ajax.ASP.NET project?</b><br />If you keep getting a javascript alert window giving the error message &quot;Sys.WebForms.PageReqeustManagerParserErrorExcpetion: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.&quot; you need to add the following setting into you system.web section in your web.config<br />&lt;pages enableViewStateMac=&quot;false&quot; viewStateEncryptionMode=&quot;Never&quot; enableEventValidation=&quot;false&quot;&gt; </li> <li><b>What version of NHibernate is NHibernate.Burrow using</b>?<br />Burrow 1.0 alpha 1 is using NHibernate 2.0 Alpha 1. </li> <li><b>What version of .Net framework does NHibernate.Burrow support?</b><br />NHibernate.Burrow currently only works in .Net Framework 2.0 </li> <li><b>Does NHibernate.Burrow create session and transaction for every http request</b>?<br />Some existing OpenSessionPerView supporting HttpModule solutions create unnecessary session and transaction for every http request including requests for digital assets such as picture and css file. NHibernate.Burrow only creates session and transaction for http request handler that needs. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>Stateful Fieldshttp://www.nhforge.org/wikis/burrow/stateful-fields/revision/3.aspxSun, 07 Sep 2008 20:44:20 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:85Fabio Maulohttp://www.nhforge.org/wikis/burrow/stateful-fields/comments.aspx<h5><strong>StatefulField Attributes</strong></h5> <p><br />We all know that in the stateless ASP.NET framework, persisting page/control&#39;s states of entity type could be a cumbersome task - for example a customerEditor.ascx needs to remember which customer it&#39;s editing. One of the common solutions is to store the Id of the entity as a value of a hidden field or into the ViewState, then load the entity from the id when needed. The code will be something like </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:300px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">private</span> Customer cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> Customer Cust {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> get</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">if</span> (ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] == <span style="color:#0000ff;">null</span>) <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (cust == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = CustomerDAO.Instance.FindById((<span style="color:#0000ff;">int</span>)ViewState[<span style="color:#006080;">&quot;custID&quot;</span>]);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">return</span> cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> set {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = <span style="color:#0000ff;">value</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">value</span> == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">else</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">value</span>.Id;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>This approach has a couple of shortcomings. First, as you can see here, it&#39;s cumbersome to do the null judgement and converting type for the Id object. If you have codes all over the application, it&#39;s duplicated code. Secondly and more importantly, it requires either ViewState or HiddenField, each has its own problem: ViewState could be disabled; HiddenField does not work well within Ajax.Asp.Net&#39;s UpdatePanel as only the HiddenFields in the updating UpdatePanel will reflect the change you made to its value.<br />Now Burrow offers a new approach - StatefulField attributes.<br /><strong>[StatefulField] attribute</strong> is the most basic one. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[StatefulField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">int</span> count = 1;</pre> </div> </div> <p>You mark a field of your control/page with the attribute [StatefulField], the value will be persistent over postbacks. [StatefulField] can be used for fields of types that are serializable - preferably primitive fields. Normally for this kind of fields, you can store them in the ViewState. However [StatefulField] attribute make the code cleaner and more importantly it can work when ViewState is disabled ( sure, there is ControlState, but this is a lot easier than ControlState isn&#39;t it? )<br /><strong>[EntityField] and [EntityFieldDeletionSafe</strong><strong>]</strong> are the enhanced versions of [StatefulField]. Both can only be used to persist entity fields in a control/page. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> CustomerEditor : UserControl</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> [EntityFieldDeletionSafe]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">protected</span> Customer customerBeingEdited;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [EntityField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> User editingAdmin;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>The CustomerEditor user control is written for administrator to edit a certain customer&#39;s profile. The above code uses the field customerBeingEdited to store the customer it&#39;s currently working on. The editingAdmin field is used to store the administrator user that is currently working with the system. Please note that [EntityField] and [EntityFieldNullSafe] should and can only be used on fields of entities that are already persisted. You cannot use them on transient entities. The major behavior difference between [EntityField] and [EntityFieldDeletionSafe] is that when you delete the entity without setting the field to null, [EntityField] will cause an Exception next time Burrow load entity value for it while [EntityFieldDeletionSafe] won&#39;t. Behind the scene, that&#39;s because that [EntityField] is using ISession.Load() to load the entity while [EntityFieldDeletionSafe] is using ISession.Get(). So the other interpretation here is that [EntityField] can return a proxy if your entity is set as LazyLoad=true, which could be a performance gain.<br /><strong>[ConversationalField]</strong> is a special version designed only for long <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation</a>. In long Burrow Conversation, you probably need to store some data that needs to have the same life span as the conversation. [ConversationField] attribute can be used for such fields. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> Checkout: Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [ConversationalField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> Order placingOrder;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> <p>A checkout page that uses long Burrow Conversation stores the currently processing order in the placingOrder field. Marked with [ConversationalField] attribute, the value of this field will have the same life span as the conversation as it is actually stored in the conversation instance. [ConversationalField] can be used on all types - not only entity but also non-entity types.<br /><strong>Important Notes:</strong></p> <ul> <li>For now, all Burrow field attributes ( [StatefulField], [EntityField], [EntityFieldDeletionSafe] or [ConversationalField] ) can only be used against protected or public fields of UserControls or Pages. Private fields marked with these attribute will be simply ignored. </li> <li>The value of these Burrow fields becomes ready at PreLoad, which is about the same as ViewState On the other hand, if you change their value after PreRenderComplete, the change won&#39;t persist. </li> </ul> <p><img width="8" height="8" src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" alt="" /></p>Stateful Fieldshttp://www.nhforge.org/wikis/burrow/stateful-fields/revision/2.aspxSun, 07 Sep 2008 19:58:26 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:82kailuowanghttp://www.nhforge.org/wikis/burrow/stateful-fields/comments.aspx<h5><b>StatefulField Attributes</b></h5> <p><br />We all know that in the stateless ASP.NET framework, persisting page/control&#39;s states of entity type could be a cumbersome task - for example a customerEditor.ascx needs to remember which customer it&#39;s editing. One of the common solutions is to store the Id of the entity as a value of a hidden field or into the ViewState, then load the entity from the id when needed. The code will be something like </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">private</span> Customer cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> Customer Cust {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> get</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">if</span> (ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] == <span style="color:#0000ff;">null</span>) <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (cust == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = CustomerDAO.Instance.FindById((<span style="color:#0000ff;">int</span>)ViewState[<span style="color:#006080;">&quot;custID&quot;</span>]);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">return</span> cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> set {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = <span style="color:#0000ff;">value</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">value</span> == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">else</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">value</span>.Id;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>This approach has a couple of shortcomings. First, as you can see here, it&#39;s cumbersome to do the null judgement and converting type for the Id object. If you have codes all over the application, it&#39;s duplicated code. Secondly and more importantly, it requires either ViewState or HiddenField, each has its own problem: ViewState could be disabled; HiddenField does not work well within Ajax.Asp.Net&#39;s UpdatePanel as only the HiddenFields in the updating UpdatePanel will reflect the change you made to its value.<br />Now Burrow offers a new approach - StatefulField attributes.<br /><b>[StatefulField] attribute</b> is the most basic one. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[StatefulField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">int</span> count = 1;</pre> </div> </div> <p>You mark a field of your control/page with the attribute [StatefulField], the value will be persistent over postbacks. [StatefulField] can be used for fields of types that are serializable - preferably primitive fields. Normally for this kind of fields, you can store them in the ViewState. However [StatefulField] attribute make the code cleaner and more importantly it can work when ViewState is disabled ( sure, there is ControlState, but this is a lot easier than ControlState isn&#39;t it? )<br /><b>[EntityField] and [EntityFieldDeletionSafe</b><b>]</b> are the enhanced versions of [StatefulField]. Both can only be used to persist entity fields in a control/page. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> CustomerEditor : UserControl</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> [EntityFieldDeletionSafe]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">protected</span> Customer customerBeingEdited;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [EntityField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> User editingAdmin;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>The CustomerEditor user control is written for administrator to edit a certain customer&#39;s profile. The above code uses the field customerBeingEdited to store the customer it&#39;s currently working on. The editingAdmin field is used to store the administrator user that is currently working with the system. Please note that [EntityField] and [EntityFieldNullSafe] should and can only be used on fields of entities that are already persisted. You cannot use them on transient entities. The major behavior difference between [EntityField] and [EntityFieldDeletionSafe] is that when you delete the entity without setting the field to null, [EntityField] will cause an Exception next time Burrow load entity value for it while [EntityFieldDeletionSafe] won&#39;t. Behind the scene, that&#39;s because that [EntityField] is using ISession.Load() to load the entity while [EntityFieldDeletionSafe] is using ISession.Get(). So the other interpretation here is that [EntityField] can return a proxy if your entity is set as LazyLoad=true, which could be a performance gain.<br /><b>[ConversationalField]</b> is a special version designed only for long <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation</a>. In long Burrow Conversation, you probably need to store some data that needs to have the same life span as the conversation. [ConversationField] attribute can be used for such fields. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> Checkout: Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [ConversationalField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> Order placingOrder;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> <p>A checkout page that uses long Burrow Conversation stores the currently processing order in the placingOrder field. Marked with [ConversationalField] attribute, the value of this field will have the same life span as the conversation as it is actually stored in the conversation instance. [ConversationalField] can be used on all types - not only entity but also non-entity types.<br /><b>Important Notes:</b></p> <ul> <li>For now, all Burrow field attributes ( [StatefulField], [EntityField], [EntityFieldDeletionSafe] or [ConversationalField] ) can only be used against protected or public fields of UserControls or Pages. Private fields marked with these attribute will be simply ignored. </li> <li>The value of these Burrow fields becomes ready at PreLoad, which is about the same as ViewState On the other hand, if you change their value after PreRenderComplete, the change won&#39;t persist. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>BurrowStatefulFieldshttp://www.nhforge.org/wikis/burrow/stateful-fields/revision/1.aspxSun, 07 Sep 2008 18:20:39 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:78kailuowanghttp://www.nhforge.org/wikis/burrow/stateful-fields/comments.aspx<h5><b>StatefulField Attributes</b></h5> <p><br />We all know that in the stateless ASP.NET framework, persisting page/control&#39;s states of entity type could be a cumbersome task - for example a customerEditor.ascx needs to remember which customer it&#39;s editing. One of the common solutions is to store the Id of the entity as a value of a hidden field or into the ViewState, then load the entity from the id when needed. The code will be something like </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">private</span> Customer cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> Customer Cust {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> get</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">if</span> (ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] == <span style="color:#0000ff;">null</span>) <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (cust == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = CustomerDAO.Instance.FindById((<span style="color:#0000ff;">int</span>)ViewState[<span style="color:#006080;">&quot;custID&quot;</span>]);</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">return</span> cust;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> set {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> cust = <span style="color:#0000ff;">value</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">value</span> == <span style="color:#0000ff;">null</span>)</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">null</span>;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">else</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> ViewState[<span style="color:#006080;">&quot;custID&quot;</span>] = <span style="color:#0000ff;">value</span>.Id;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> }</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>This approach has a couple of shortcomings. First, as you can see here, it&#39;s cumbersome to do the null judgement and converting type for the Id object. If you have codes all over the application, it&#39;s duplicated code. Secondly and more importantly, it requires either ViewState or HiddenField, each has its own problem: ViewState could be disabled; HiddenField does not work well within Ajax.Asp.Net&#39;s UpdatePanel as only the HiddenFields in the updating UpdatePanel will reflect the change you made to its value.<br />Now Burrow offers a new approach - StatefulField attributes.<br /><b>[StatefulField] attribute</b> is the most basic one. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[StatefulField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">int</span> count = 1;</pre> </div> </div> <p>You mark a field of your control/page with the attribute [StatefulField], the value will be persistent over postbacks. [StatefulField] can be used for fields of types that are serializable - preferably primitive fields. Normally for this kind of fields, you can store them in the ViewState. However [StatefulField] attribute make the code cleaner and more importantly it can work when ViewState is disabled ( sure, there is ControlState, but this is a lot easier than ControlState isn&#39;t it? )<br /><b>[EntityField] and [EntityFieldDeletionSafe</b><b>]</b> are the enhanced versions of [StatefulField]. Both can only be used to persist entity fields in a control/page. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> CustomerEditor : UserControl</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">{</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> [EntityFieldDeletionSafe]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <span style="color:#0000ff;">protected</span> Customer customerBeingEdited;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [EntityField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> User editingAdmin;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">}</pre> </div> </div> <p>The CustomerEditor user control is written for administrator to edit a certain customer&#39;s profile. The above code uses the field customerBeingEdited to store the customer it&#39;s currently working on. The editingAdmin field is used to store the administrator user that is currently working with the system. Please note that [EntityField] and [EntityFieldNullSafe] should and can only be used on fields of entities that are already persisted. You cannot use them on transient entities. The major behavior difference between [EntityField] and [EntityFieldDeletionSafe] is that when you delete the entity without setting the field to null, [EntityField] will cause an Exception next time Burrow load entity value for it while [EntityFieldDeletionSafe] won&#39;t. Behind the scene, that&#39;s because that [EntityField] is using ISession.Load() to load the entity while [EntityFieldDeletionSafe] is using ISession.Get(). So the other interpretation here is that [EntityField] can return a proxy if your entity is set as LazyLoad=true, which could be a performance gain.<br /><b>[ConversationalField]</b> is a special version designed only for long <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained">Burrow Conversation</a>. In long Burrow Conversation, you probably need to store some data that needs to have the same life span as the conversation. [ConversationField] attribute can be used for such fields. Here is an example: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> Checkout: Page {</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> [ConversationalField]</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> <span style="color:#0000ff;">protected</span> Order placingOrder;</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">}</pre> </div> </div> <p>A checkout page that uses long Burrow Conversation stores the currently processing order in the placingOrder field. Marked with [ConversationalField] attribute, the value of this field will have the same life span as the conversation as it is actually stored in the conversation instance. [ConversationalField] can be used on all types - not only entity but also non-entity types.<br /><b>Important Notes:</b></p> <ul> <li>For now, all Burrow field attributes ( [StatefulField], [EntityField], [EntityFieldDeletionSafe] or [ConversationalField] ) can only be used against protected or public fields of UserControls or Pages. Private fields marked with these attribute will be simply ignored. </li> <li>The value of these Burrow fields becomes ready at PreLoad, which is about the same as ViewState On the other hand, if you change their value after PreRenderComplete, the change won&#39;t persist. </li> </ul> <p><img src="http://nhcontrib.wiki.sourceforge.net/i/bTLin.gif" height="8" width="8" alt="" /></p>Conversation Explainedhttp://www.nhforge.org/wikis/burrow/conversation-explained/revision/5.aspxSun, 07 Sep 2008 19:54:46 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:77kailuowanghttp://www.nhforge.org/wikis/burrow/conversation-explained/comments.aspx<p>&nbsp;</p> <p><b>Burrow Conversation</b> is the core concept of NHibernate.Burrow. It was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>.<br />The concept Conversation is to represent a stateful business transaction between end-user and system. Burrow manages NH session and transaction(optional) around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of it (note: transaction strategy will be discussed later).<br />Burrow Conversation can be a long conversation between user and system - it can span over multiple http requests. In another sentence, Burrow Conversation allows end user to have a stateful business transaction with the system that spans over multiple http requests and responses. A common example of such long conversation is a checkout process - user enters shipping information, billing information and confirm the order information in multiple steps.<br />More importantly, like in Seam, one user can have multiple Burrow Conversations with the system simultaneously. For example, user can use one browser window/tab to checkout his shopping cart and another browser window/tab to process an order return and another browser window/tab to modify his/her account information. This feature is not only beneficial but also required because it&#39;s very hard for the web application to stop user from opening multiple browser window/tabs interacting with the system, which could cause serious concurrency problem if multi-conversation is not supported (This could happen if you simple store NHibernate Session in HttpSession to support long Session). </p> <h4><b>Short Burrow Conversation</b></h4> <p>By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request - we call it a short conversation. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request. This takes care of most business transactions that require only one http request, for example, modifying the customer information. Burrow takes care of this type of short conversation transparently - your code does not even need to be aware of Burrow Conversation. </p> <h4><b>Long Burrow Conversation</b></h4> <p>If you need to have a long conversation, you need to know a little about the NHibernate.Burrow.IConversation interface. We are going to explain it here.<br />In the request that you are going to start a long conversation - for example when you start a checkout process - you need to ask the current Burrow Conversation to span. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//Get a facade instance of burrow, it&#39;s free</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#008000;">//ask the current IConversation to span with PostBacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> </div> </div> <p>bf.CurrentConversation gives you the current IConversation (the interface represents Burrow Conversation) you are in. It was a short conversation before. IConversation.SpanWithPostBacks() tells the conversation to span with the post backs of a form. Now it becomes a long conversation. In pages that have only one form, this means that the conversation will be spanning as long as the user stays in the same page - the following postback requests will be using the same IConversation as this one. If the user goes to another page or close the current browser window/tab, the conversation will be discarded (If you need the conversation to span to another page, [[burrow:#SpanByUrl|click here]]).<br />After the long business transaction is done - for example, the user finally confirmed the placement of the order in the checkout - you need to tell the Long Conversation to stop spanning (BTW, it&#39;s not needed for short conversation). Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.FinishSpan(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>Burrow will commit the conversation at the end of this request - it will close the conversation. The next request will be assigned with a new conversation.<br />Also, you can cancel the conversation in the middle of it - for example user clicks the cancel button or something goes wrong. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>The conversation won&#39;t be discarded immediately, but Burrow will rollback the transaction and close the conversation at the end of this request. This way all the data changes in this conversation won&#39;t be committed to database, but you can still read data from Database in this request - for example to display some user friendly error message. If something quite fatal happens and you really want to immediately cancel the current conversation, you can either throw an exception or do the following:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// note: bf is the BurrowFramework instance. you can create it anywhere.</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">bf.CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> </div> </div> <p>After you called bf.CloseWorkSpace(), you&#39;ll probably need to immediately redirect to another page as Burrow managed services are no longer available for this request.</p> <h4>Transaction Strategy in Conversation</h4> <p><br />I know you must have noticed the TransactionStrategy parameter we passed to SpanWithPostBacks() method, this parameter tells Burrow how to manage transactions for this long conversation. There are three of them for you to choose. </p> <ul> <li>By default, that is, if you don&#39;t pass a TransactionStrategy to the method, Burrow will use one transaction per request pattern - it opens the transaction at the beginning of the request and commit it at the end of the request, which means that the long conversation is break into multiple atomic transactions, data change will be updated to DB on every request! </li> <li><b>TransactionStrategy.LongDBTransaction</b> - I know some people will need a long atomic conversation for some business transaction such as the example we just gave. If you pass this strategy to the method, Burrow will open keep the DB transaction alive until the conversation ends. Now the data changes will only get updated to DB after the whole long conversation is successfully finished. The long conversation is atomic now. However, the bad news is that now Burrow has to keep a long DB transaction and connection for this long conversation over multiple requests, even when user is thinking or wonders away. Fortunately we have the last strategy. </li> <li><b>TransactionStrategy.BusinessTransaction</b> - this strategy is the recommended one if you need an atomic but long conversation. This strategy will still use the one db transaction per request pattern - as in the default strategy. But, it will turn the NHibernate .Session.FlushMode to Never, and only flush the session when the conversation ends (or when you specifically command to flush session). This way, data change won&#39;t get updated to DB until the end of the long conversation. The conversation is atomic again. There is one issue here though, you lost the auto session flush feature NHibernate provides, one consequence will be that if you make some data change, it may not reflect in the query results later in the same long conversation. </li> </ul> <p>Other than these three transaction strategies, you can set Burrow to leave the transaction to your own management, that is Burrow will no longer manage the transaction, you can and need to use BurrowFramework.CurrentConversation.TransactionManager to manage it. To use manual transaction management, set manualTransactionManagement=&quot;true&quot; in the NHibernate.Burrow Section </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> manualTransactionManagement=&quot;true&quot; <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> ...</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That is the handling for most long conversation scenarios. The following are a couple of special cases:<br /><a name="SpanByUrl"></a><b>Span by URL</b><br />If you need the long conversation to span to another page, you still call SpanWithPostBack() method, but then you&#39;ll need to wrap the url of that page with conversation information so that Burrow will pick up the conversation for it. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">WebUtil wu = <span style="color:#0000ff;">new</span> WebUtil();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#008000;">//use the following url instead of &quot;~/anotherPage.aspx&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">string</span> urlToAnotherPage = wu.WrapUrlWithConversationInfo(<span style="color:#006080;">&quot;~/anotherPage.aspx&quot;</span>);</pre> </div> </div> <p>If you need a link on your page, you can either use this API to wrap the link, or you can use the NHibernate.Burrow.WebUtil.Controls.BurrowLink control. It inherits from HyperLink so you can use it exactly the same as HyperLink but it will automatically wrap the conversation information for you.<br /><a name="SpanByCookie"></a><b>Span by Cookie</b><br />Another way to span a conversation is IConverastion.SpanWithCookie(string workSpaceName); This will store the conversation information into browser cookies. However not all pages that picks up that cookie will pick up that conversation, which is unmanageable and dangerous. The concept WorkSpaceName is introduced to help here. You can group your HttpHandlers using this WorkSpaceName - HttpHandlers defined with the same WorkSpaceName can be deemed as being in the same WorkSpace. When you call CurrentConversation.SpanWithCookie(string workSpaceName) only the HttpHandlers defined with the same workSpaceName will be sharing that conversation. Here is an example of how it works:<br />Define the WorkSpaceName for APageInWorkSpaceA.aspx:</p> <pre>&nbsp;</pre> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[NHibernate.Burrow.WebUtil.Attributes.WorkSpaceInfo(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>)] <span style="color:#008000;">//Define the page&#39;s workspace using Attribute</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> SharingConversations_Step06b : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">{}</pre> </div> </div> <p>Start spanning in another page: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.SpanWithCookie(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>);</pre> </div> </div> <p>Now if user opens APageInWorkSpaceA.aspx in the same browser session, the request will be using the same conversation. As for Finish or GiveUp, there is no difference from long conversation spanning with postbacks.<br />If attribute is not enough for defining page&#39;s workSpaceName, as it&#39;s static, you can create your own Handler-WorkSpace management mechanism and implement the IWorkSpaceNameSniffer interface in Web.Util, that interface is in charge of getting the WorkSpaceName of an IHttpHandler. You can set in the Burrow Configuration the type of implementation of that interface the system should use ( Please look at NHibernate.Burrow.IBurrowConfig ).</p>Conversation Explainedhttp://www.nhforge.org/wikis/burrow/conversation-explained/revision/4.aspxSun, 07 Sep 2008 19:43:18 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:76kailuowanghttp://www.nhforge.org/wikis/burrow/conversation-explained/comments.aspx<p>&nbsp;</p> <p><b>Burrow Conversation</b> is the core concept of NHibernate.Burrow. It was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>.<br />The concept Conversation is to represent a stateful business transaction between end-user and system. Burrow manages NH session and transaction(optional) around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of it (note: transaction strategy will be discussed later).<br />Burrow Conversation can be a long conversation between user and system - it can span over multiple http requests. In another sentence, Burrow Conversation allows end user to have a stateful business transaction with the system that spans over multiple http requests and responses. A common example of such long conversation is a checkout process - user enters shipping information, billing information and confirm the order information in multiple steps.<br />More importantly, like in Seam, one user can have multiple Burrow Conversations with the system simultaneously. For example, user can use one browser window/tab to checkout his shopping cart and another browser window/tab to process an order return and another browser window/tab to modify his/her account information. This feature is not only beneficial but also required because it&#39;s very hard for the web application to stop user from opening multiple browser window/tabs interacting with the system, which could cause serious concurrency problem if multi-conversation is not supported (This could happen if you simple store NHibernate Session in HttpSession to support long Session). </p> <h4><b>Short Burrow Conversation</b></h4> <p>By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request - we call it a short conversation. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request. This takes care of most business transactions that require only one http request, for example, modifying the customer information. Burrow takes care of this type of short conversation transparently - your code does not even need to be aware of Burrow Conversation. </p> <h4><b>Long Burrow Conversation</b></h4> <p>If you need to have a long conversation, you need to know a little about the NHibernate.Burrow.IConversation interface. We are going to explain it here.<br />In the request that you are going to start a long conversation - for example when you start a checkout process - you need to ask the current Burrow Conversation to span. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//Get a facade instance of burrow, it&#39;s free</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#008000;">//ask the current IConversation to span with PostBacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> </div> </div> <p>bf.CurrentConversation gives you the current IConversation (the interface represents Burrow Conversation) you are in. It was a short conversation before. IConversation.SpanWithPostBacks() tells the conversation to span with the post backs of a form. Now it becomes a long conversation. In pages that have only one form, this means that the conversation will be spanning as long as the user stays in the same page - the following postback requests will be using the same IConversation as this one. If the user goes to another page or close the current browser window/tab, the conversation will be discarded (If you need the conversation to span to another page, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained#SpanByUrl">click here</a>).<br />After the long business transaction is done - for example, the user finally confirmed the placement of the order in the checkout - you need to tell the Long Conversation to stop spanning (BTW, it&#39;s not needed for short conversation). Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.FinishSpan(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>Burrow will commit the conversation at the end of this request - it will close the conversation. The next request will be assigned with a new conversation.<br />Also, you can cancel the conversation in the middle of it - for example user clicks the cancel button or something goes wrong. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>The conversation won&#39;t be discarded immediately, but Burrow will rollback the transaction and close the conversation at the end of this request. This way all the data changes in this conversation won&#39;t be committed to database, but you can still read data from Database in this request - for example to display some user friendly error message. If something quite fatal happens and you really want to immediately cancel the current conversation, you can either throw an exception or do the following:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// note: bf is the BurrowFramework instance. you can create it anywhere.</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">bf.CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> </div> </div> <p>After you called bf.CloseWorkSpace(), you&#39;ll probably need to immediately redirect to another page as Burrow managed services are no longer available for this request.</p> <h4>Transaction Strategy in Conversation</h4> <p><br />I know you must have noticed the TransactionStrategy parameter we passed to SpanWithPostBacks() method, this parameter tells Burrow how to manage transactions for this long conversation. There are three of them for you to choose. </p> <ul> <li>By default, that is, if you don&#39;t pass a TransactionStrategy to the method, Burrow will use one transaction per request pattern - it opens the transaction at the beginning of the request and commit it at the end of the request, which means that the long conversation is break into multiple atomic transactions, data change will be updated to DB on every request! </li> <li><b>TransactionStrategy.LongDBTransaction</b> - I know some people will need a long atomic conversation for some business transaction such as the example we just gave. If you pass this strategy to the method, Burrow will open keep the DB transaction alive until the conversation ends. Now the data changes will only get updated to DB after the whole long conversation is successfully finished. The long conversation is atomic now. However, the bad news is that now Burrow has to keep a long DB transaction and connection for this long conversation over multiple requests, even when user is thinking or wonders away. Fortunately we have the last strategy. </li> <li><b>TransactionStrategy.BusinessTransaction</b> - this strategy is the recommended one if you need an atomic but long conversation. This strategy will still use the one db transaction per request pattern - as in the default strategy. But, it will turn the NHibernate .Session.FlushMode to Never, and only flush the session when the conversation ends (or when you specifically command to flush session). This way, data change won&#39;t get updated to DB until the end of the long conversation. The conversation is atomic again. There is one issue here though, you lost the auto session flush feature NHibernate provides, one consequence will be that if you make some data change, it may not reflect in the query results later in the same long conversation. </li> </ul> <p>Other than these three transaction strategies, you can set Burrow to leave the transaction to your own management, that is Burrow will no longer manage the transaction, you can and need to use BurrowFramework.CurrentConversation.TransactionManager to manage it. To use manual transaction management, set manualTransactionManagement=&quot;true&quot; in the NHibernate.Burrow Section </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> manualTransactionManagement=&quot;true&quot; <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> ...</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That is the handling for most long conversation scenarios. The following are a couple of special cases:<br /><a name="SpanByUrl"></a><b>Span by URL</b><br />If you need the long conversation to span to another page, you still call SpanWithPostBack() method, but then you&#39;ll need to wrap the url of that page with conversation information so that Burrow will pick up the conversation for it. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">WebUtil wu = <span style="color:#0000ff;">new</span> WebUtil();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#008000;">//use the following url instead of &quot;~/anotherPage.aspx&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">string</span> urlToAnotherPage = wu.WrapUrlWithConversationInfo(<span style="color:#006080;">&quot;~/anotherPage.aspx&quot;</span>);</pre> </div> </div> <p>If you need a link on your page, you can either use this API to wrap the link, or you can use the NHibernate.Burrow.WebUtil.Controls.BurrowLink control. It inherits from HyperLink so you can use it exactly the same as HyperLink but it will automatically wrap the conversation information for you.<br /><a name="SpanByCookie"></a><b>Span by Cookie</b><br />Another way to span a conversation is IConverastion.SpanWithCookie(string workSpaceName); This will store the conversation information into browser cookies. However not all pages that picks up that cookie will pick up that conversation, which is unmanageable and dangerous. The concept WorkSpaceName is introduced to help here. You can group your HttpHandlers using this WorkSpaceName - HttpHandlers defined with the same WorkSpaceName can be deemed as being in the same WorkSpace. When you call CurrentConversation.SpanWithCookie(string workSpaceName) only the HttpHandlers defined with the same workSpaceName will be sharing that conversation. Here is an example of how it works:<br />Define the WorkSpaceName for APageInWorkSpaceA.aspx:</p> <pre>&nbsp;</pre> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[NHibernate.Burrow.WebUtil.Attributes.WorkSpaceInfo(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>)] <span style="color:#008000;">//Define the page&#39;s workspace using Attribute</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> SharingConversations_Step06b : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">{}</pre> </div> </div> <p>Start spanning in another page: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.SpanWithCookie(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>);</pre> </div> </div> <p>Now if user opens APageInWorkSpaceA.aspx in the same browser session, the request will be using the same conversation. As for Finish or GiveUp, there is no difference from long conversation spanning with postbacks.<br />If attribute is not enough for defining page&#39;s workSpaceName, as it&#39;s static, you can create your own Handler-WorkSpace management mechanism and implement the IWorkSpaceNameSniffer interface in Web.Util, that interface is in charge of getting the WorkSpaceName of an IHttpHandler. You can set in the Burrow Configuration the type of implementation of that interface the system should use ( Please look at NHibernate.Burrow.IBurrowConfig ).</p>BurrowConversationExplainedhttp://www.nhforge.org/wikis/burrow/conversation-explained/revision/3.aspxSun, 07 Sep 2008 18:12:01 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:75kailuowanghttp://www.nhforge.org/wikis/burrow/conversation-explained/comments.aspx<p>&nbsp;</p> <p><b>Burrow Conversation</b> is the core concept of NHibernate.Burrow. It was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>.<br />The concept Conversation is to represent a stateful business transaction between end-user and system. Burrow manages NH session and transaction(optional) around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of it (note: transaction strategy will be discussed later).<br />Burrow Conversation can be a long conversation between user and system - it can span over multiple http requests. In another sentence, Burrow Conversation allows end user to have a stateful business transaction with the system that spans over multiple http requests and responses. A common example of such long conversation is a checkout process - user enters shipping information, billing information and confirm the order information in multiple steps.<br />More importantly, like in Seam, one user can have multiple Burrow Conversations with the system simultaneously. For example, user can use one browser window/tab to checkout his shopping cart and another browser window/tab to process an order return and another browser window/tab to modify his/her account information. This feature is not only beneficial but also required because it&#39;s very hard for the web application to stop user from opening multiple browser window/tabs interacting with the system, which could cause serious concurrency problem if multi-conversation is not supported (This could happen if you simple store NHibernate Session in HttpSession to support long Session). </p> <h4><b>Short Burrow Conversation</b></h4> <p>By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request - we call it a short conversation. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request. This takes care of most business transactions that require only one http request, for example, modifying the customer information. Burrow takes care of this type of short conversation transparently - your code does not even need to be aware of Burrow Conversation. </p> <h4><b>Long Burrow Conversation</b></h4> <p>If you need to have a long conversation, you need to know a little about the NHibernate.Burrow.IConversation interface. We are going to explain it here.<br />In the request that you are going to start a long conversation - for example when you start a checkout process - you need to ask the current Burrow Conversation to span. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//Get a facade instance of burrow, it&#39;s free</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#008000;">//ask the current IConversation to span with PostBacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> </div> </div> <p>bf.CurrentConversation gives you the current IConversation (the interface represents Burrow Conversation) you are in. It was a short conversation before. IConversation.SpanWithPostBacks() tells the conversation to span with the post backs of a form. Now it becomes a long conversation. In pages that have only one form, this means that the conversation will be spanning as long as the user stays in the same page - the following postback requests will be using the same IConversation as this one. If the user goes to another page or close the current browser window/tab, the conversation will be discarded (If you need the conversation to span to another page, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained#SpanByUrl">click here</a>).<br />After the long business transaction is done - for example, the user finally confirmed the placement of the order in the checkout - you need to tell the Long Conversation to stop spanning (BTW, it&#39;s not needed for short conversation). Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.FinishSpan(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>Burrow will commit the conversation at the end of this request - it will close the conversation. The next request will be assigned with a new conversation.<br />Also, you can cancel the conversation in the middle of it - for example user clicks the cancel button or something goes wrong. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>The conversation won&#39;t be discarded immediately, but Burrow will rollback the transaction and close the conversation at the end of this request. This way all the data changes in this conversation won&#39;t be committed to database, but you can still read data from Database in this request - for example to display some user friendly error message. If something quite fatal happens and you really want to immediately cancel the current conversation, you can either throw an exception or do the following:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// note: bf is the BurrowFramework instance. you can create it anywhere.</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">bf.CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> </div> </div> <p>After you called bf.CloseWorkSpace(), you&#39;ll probably need to immediately redirect to another page as Burrow managed services are no longer available for this request.</p> <h4>Transaction Strategy in Conversation</h4> <p><br />I know you must have noticed the TransactionStrategy parameter we passed to SpanWithPostBacks() method, this parameter tells Burrow how to manage transactions for this long conversation. There are three of them for you to choose. </p> <ul> <li>By default, that is, if you don&#39;t pass a TransactionStrategy to the method, Burrow will use one transaction per request pattern - it opens the transaction at the beginning of the request and commit it at the end of the request, which means that the long conversation is break into multiple atomic transactions, data change will be updated to DB on every request! </li> <li><b>TransactionStrategy.LongDBTransaction</b> - I know some people will need a long atomic conversation for some business transaction such as the example we just gave. If you pass this strategy to the method, Burrow will open keep the DB transaction alive until the conversation ends. Now the data changes will only get updated to DB after the whole long conversation is successfully finished. The long conversation is atomic now. However, the bad news is that now Burrow has to keep a long DB transaction and connection for this long conversation over multiple requests, even when user is thinking or wonders away. Fortunately we have the last strategy. </li> <li><b>TransactionStrategy.BusinessTransaction</b> - this strategy is the recommended one if you need an atomic but long conversation. This strategy will still use the one db transaction per request pattern - as in the default strategy. But, it will turn the NHibernate .Session.FlushMode to Never, and only flush the session when the conversation ends (or when you specifically command to flush session). This way, data change won&#39;t get updated to DB until the end of the long conversation. The conversation is atomic again. There is one issue here though, you lost the auto session flush feature NHibernate provides, one consequence will be that if you make some data change, it may not reflect in the query results later in the same long conversation. </li> </ul> <p>Other than these three transaction strategies, you can set Burrow to leave the transaction to your own management, that is Burrow will no longer manage the transaction, you can and need to use BurrowFramework.CurrentConversation.TransactionManager to manage it. To use manual transaction management, set manualTransactionManagement=&quot;true&quot; in the NHibernate.Burrow Section </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> manualTransactionManagement=&quot;true&quot; <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> ...</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That is the handling for most long conversation scenarios. The following are a couple of special cases:<br /><a name="SpanByUrl"></a><b>Span by URL</b><br />If you need the long conversation to span to another page, you still call SpanWithPostBack() method, but then you&#39;ll need to wrap the url of that page with conversation information so that Burrow will pick up the conversation for it. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">WebUtil wu = <span style="color:#0000ff;">new</span> WebUtil();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#008000;">//use the following url instead of &quot;~/anotherPage.aspx&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">string</span> urlToAnotherPage = wu.WrapUrlWithConversationInfo(<span style="color:#006080;">&quot;~/anotherPage.aspx&quot;</span>);</pre> </div> </div> <p>If you need a link on your page, you can either use this API to wrap the link, or you can use the NHibernate.Burrow.WebUtil.Controls.BurrowLink control. It inherits from HyperLink so you can use it exactly the same as HyperLink but it will automatically wrap the conversation information for you.<br /><a name="SpanByCookie"></a><b>Span by Cookie</b><br />Another way to span a conversation is IConverastion.SpanWithCookie(string workSpaceName); This will store the conversation information into browser cookies. However not all pages that picks up that cookie will pick up that conversation, which is unmanageable and dangerous. The concept WorkSpaceName is introduced to help here. You can group your HttpHandlers using this WorkSpaceName - HttpHandlers defined with the same WorkSpaceName can be deemed as being in the same WorkSpace. When you call CurrentConversation.SpanWithCookie(string workSpaceName) only the HttpHandlers defined with the same workSpaceName will be sharing that conversation. Here is an example of how it works:<br />Define the WorkSpaceName for APageInWorkSpaceA.aspx:</p> <pre>&nbsp;</pre> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[NHibernate.Burrow.WebUtil.Attributes.WorkSpaceInfo(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>)] <span style="color:#008000;">//Define the page&#39;s workspace using Attribute</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> SharingConversations_Step06b : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">{}</pre> </div> </div> <p>Start spanning in another page: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.SpanWithCookie(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>);</pre> </div> </div> <p>Now if user opens APageInWorkSpaceA.aspx in the same browser session, the request will be using the same conversation. As for Finish or GiveUp, there is no difference from long conversation spanning with postbacks.<br />If attribute is not enough for defining page&#39;s workSpaceName, as it&#39;s static, you can create your own Handler-WorkSpace management mechanism and implement the IWorkSpaceNameSniffer interface in Web.Util, that interface is in charge of getting the WorkSpaceName of an IHttpHandler. You can set in the Burrow Configuration the type of implementation of that interface the system should use ( Please look at NHibernate.Burrow.IBurrowConfig ).</p>BurrowConversationExplainedhttp://www.nhforge.org/wikis/burrow/conversation-explained/revision/2.aspxSun, 07 Sep 2008 18:12:01 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:72kailuowanghttp://www.nhforge.org/wikis/burrow/conversation-explained/comments.aspx<p>&nbsp;</p> <p><b>Burrow Conversation</b> is the core concept of NHibernate.Burrow. It was inspired by the Conversation concept in <a href="http://www.jboss.com/products/seam">JBoss Seam </a>.<br />The concept Conversation is to represent a stateful business transaction between end-user and system. Burrow manages NH session and transaction(optional) around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of it (note: transaction strategy will be discussed later).<br />Burrow Conversation can be a long conversation between user and system - it can span over multiple http requests. In another sentence, Burrow Conversation allows end user to have a stateful business transaction with the system that spans over multiple http requests and responses. A common example of such long conversation is a checkout process - user enters shipping information, billing information and confirm the order information in multiple steps.<br />More importantly, like in Seam, one user can have multiple Burrow Conversations with the system simultaneously. For example, user can use one browser window/tab to checkout his shopping cart and another browser window/tab to process an order return and another browser window/tab to modify his/her account information. This feature is not only beneficial but also required because it&#39;s very hard for the web application to stop user from opening multiple browser window/tabs interacting with the system, which could cause serious concurrency problem if multi-conversation is not supported (This could happen if you simple store NHibernate Session in HttpSession to support long Session). </p> <h4><b>Short Burrow Conversation</b></h4> <p>By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request - we call it a short conversation. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request. This takes care of most business transactions that require only one http request, for example, modifying the customer information. Burrow takes care of this type of short conversation transparently - your code does not even need to be aware of Burrow Conversation. </p> <h4><b>Long Burrow Conversation</b></h4> <p>If you need to have a long conversation, you need to know a little about the NHibernate.Burrow.IConversation interface. We are going to explain it here.<br />In the request that you are going to start a long conversation - for example when you start a checkout process - you need to ask the current Burrow Conversation to span. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 1:</span> <span style="color:#008000;">//Get a facade instance of burrow, it&#39;s free</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 2:</span> BurrowFramework bf = <span style="color:#0000ff;">new</span> BurrowFramework();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 3:</span> </pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#606060;"> 4:</span> <span style="color:#008000;">//ask the current IConversation to span with PostBacks</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#606060;"> 5:</span> bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);</pre> </div> </div> <p>bf.CurrentConversation gives you the current IConversation (the interface represents Burrow Conversation) you are in. It was a short conversation before. IConversation.SpanWithPostBacks() tells the conversation to span with the post backs of a form. Now it becomes a long conversation. In pages that have only one form, this means that the conversation will be spanning as long as the user stays in the same page - the following postback requests will be using the same IConversation as this one. If the user goes to another page or close the current browser window/tab, the conversation will be discarded (If you need the conversation to span to another page, <a href="http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained#SpanByUrl">click here</a>).<br />After the long business transaction is done - for example, the user finally confirmed the placement of the order in the checkout - you need to tell the Long Conversation to stop spanning (BTW, it&#39;s not needed for short conversation). Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.FinishSpan(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>Burrow will commit the conversation at the end of this request - it will close the conversation. The next request will be assigned with a new conversation.<br />Also, you can cancel the conversation in the middle of it - for example user clicks the cancel button or something goes wrong. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); // note: bf <span style="color:#0000ff;">is</span> the BurrowFramework instance. you can create it anywhere.</pre> </div> </div> <p>The conversation won&#39;t be discarded immediately, but Burrow will rollback the transaction and close the conversation at the end of this request. This way all the data changes in this conversation won&#39;t be committed to database, but you can still read data from Database in this request - for example to display some user friendly error message. If something quite fatal happens and you really want to immediately cancel the current conversation, you can either throw an exception or do the following:</p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.GiveUp(); <span style="color:#008000;">// note: bf is the BurrowFramework instance. you can create it anywhere.</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;">bf.CloseWorkSpace();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"> </pre> </div> </div> <p>After you called bf.CloseWorkSpace(), you&#39;ll probably need to immediately redirect to another page as Burrow managed services are no longer available for this request.</p> <h4>Transaction Strategy in Conversation</h4> <p><br />I know you must have noticed the TransactionStrategy parameter we passed to SpanWithPostBacks() method, this parameter tells Burrow how to manage transactions for this long conversation. There are three of them for you to choose. </p> <ul> <li>By default, that is, if you don&#39;t pass a TransactionStrategy to the method, Burrow will use one transaction per request pattern - it opens the transaction at the beginning of the request and commit it at the end of the request, which means that the long conversation is break into multiple atomic transactions, data change will be updated to DB on every request! </li> <li><b>TransactionStrategy.LongDBTransaction</b> - I know some people will need a long atomic conversation for some business transaction such as the example we just gave. If you pass this strategy to the method, Burrow will open keep the DB transaction alive until the conversation ends. Now the data changes will only get updated to DB after the whole long conversation is successfully finished. The long conversation is atomic now. However, the bad news is that now Burrow has to keep a long DB transaction and connection for this long conversation over multiple requests, even when user is thinking or wonders away. Fortunately we have the last strategy. </li> <li><b>TransactionStrategy.BusinessTransaction</b> - this strategy is the recommended one if you need an atomic but long conversation. This strategy will still use the one db transaction per request pattern - as in the default strategy. But, it will turn the NHibernate .Session.FlushMode to Never, and only flush the session when the conversation ends (or when you specifically command to flush session). This way, data change won&#39;t get updated to DB until the end of the long conversation. The conversation is atomic again. There is one issue here though, you lost the auto session flush feature NHibernate provides, one consequence will be that if you make some data change, it may not reflect in the query results later in the same long conversation. </li> </ul> <p>Other than these three transaction strategies, you can set Burrow to leave the transaction to your own management, that is Burrow will no longer manage the transaction, you can and need to use BurrowFramework.CurrentConversation.TransactionManager to manage it. To use manual transaction management, set manualTransactionManagement=&quot;true&quot; in the NHibernate.Burrow Section </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;</span><span style="color:#800000;">NHibernate.Burrow</span> manualTransactionManagement=&quot;true&quot; <span style="color:#0000ff;">&gt;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> ...</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">NHibernate.Burrow</span><span style="color:#0000ff;">&gt;</span></pre> </div> </div> <p><br />That is the handling for most long conversation scenarios. The following are a couple of special cases:<br /><a name="SpanByUrl"></a><b>Span by URL</b><br />If you need the long conversation to span to another page, you still call SpanWithPostBack() method, but then you&#39;ll need to wrap the url of that page with conversation information so that Burrow will pick up the conversation for it. Here is how: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">WebUtil wu = <span style="color:#0000ff;">new</span> WebUtil();</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#008000;">//use the following url instead of &quot;~/anotherPage.aspx&quot;</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;"><span style="color:#0000ff;">string</span> urlToAnotherPage = wu.WrapUrlWithConversationInfo(<span style="color:#006080;">&quot;~/anotherPage.aspx&quot;</span>);</pre> </div> </div> <p>If you need a link on your page, you can either use this API to wrap the link, or you can use the NHibernate.Burrow.WebUtil.Controls.BurrowLink control. It inherits from HyperLink so you can use it exactly the same as HyperLink but it will automatically wrap the conversation information for you.<br /><a name="SpanByCookie"></a><b>Span by Cookie</b><br />Another way to span a conversation is IConverastion.SpanWithCookie(string workSpaceName); This will store the conversation information into browser cookies. However not all pages that picks up that cookie will pick up that conversation, which is unmanageable and dangerous. The concept WorkSpaceName is introduced to help here. You can group your HttpHandlers using this WorkSpaceName - HttpHandlers defined with the same WorkSpaceName can be deemed as being in the same WorkSpace. When you call CurrentConversation.SpanWithCookie(string workSpaceName) only the HttpHandlers defined with the same workSpaceName will be sharing that conversation. Here is an example of how it works:<br />Define the WorkSpaceName for APageInWorkSpaceA.aspx:</p> <pre>&nbsp;</pre> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">[NHibernate.Burrow.WebUtil.Attributes.WorkSpaceInfo(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>)] <span style="color:#008000;">//Define the page&#39;s workspace using Attribute</span></pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">partial</span> <span style="color:#0000ff;">class</span> SharingConversations_Step06b : System.Web.UI.Page</pre> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">{}</pre> </div> </div> <p>Start spanning in another page: </p> <div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;font-size:8pt;width:97.5%;cursor:text;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;max-height:200px;"> <div style="border-style:none;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:#f4f4f4;"> <pre style="border-style:none;margin:0em;padding:0px;overflow:visible;font-size:8pt;width:100%;color:black;line-height:12pt;font-family:consolas,&#39;Courier New&#39;,courier,monospace;background-color:white;">bf.CurrentConversation.SpanWithCookie(<span style="color:#006080;">&quot;WorkSpace1&quot;</span>);</pre> </div> </div> <p>Now if user opens APageInWorkSpaceA.aspx in the same browser session, the request will be using the same conversation. As for Finish or GiveUp, there is no difference from long conversation spanning with postbacks.<br />If attribute is not enough for defining page&#39;s workSpaceName, as it&#39;s static, you can create your own Handler-WorkSpace management mechanism and implement the IWorkSpaceNameSniffer interface in Web.Util, that interface is in charge of getting the WorkSpaceName of an IHttpHandler. You can set in the Burrow Configuration the type of implementation of that interface the system should use ( Please look at NHibernate.Burrow.IBurrowConfig ).</p>BurrowConversationExplainedhttp://www.nhforge.org/wikis/burrow/conversation-explained/revision/1.aspxSun, 07 Sep 2008 18:11:25 GMT45f813f2-f1c4-4eda-a619-288e3cadc793:65kailuowanghttp://www.nhforge.org/wikis/burrow/conversation-explained/comments.aspx<p>&lt;p&gt;&lt;/p&gt;<br />&lt;p&gt;&lt;strong&gt;Burrow Conversation&lt;/strong&gt; is the core concept of NHibernate.Burrow. It was inspired by the Conversation concept in &lt;a href=&quot;http://www.jboss.com/products/seam&quot;&gt;JBoss Seam &lt;/a&gt;.&lt;br&gt;The concept Conversation is to represent a stateful business transaction between end-user and system. Burrow manages NH session and transaction(optional) around conversation - it opens a session at the beginning of each conversation, and then close the session at the end of it (note: transaction strategy will be discussed later).&lt;br&gt;Burrow Conversation can be a long conversation between user and system - it can span over multiple http requests. In another sentence, Burrow Conversation allows end user to have a stateful business transaction with the system that spans over multiple http requests and responses. A common example of such long conversation is a checkout process - user enters shipping information, billing information and confirm the order information in multiple steps.&lt;br&gt;More importantly, like in Seam, one user can have multiple Burrow Conversations with the system simultaneously. For example, user can use one browser window/tab to checkout his shopping cart and another browser window/tab to process an order return and another browser window/tab to modify his/her account information. This feature is not only beneficial but also required because it&#39;s very hard for the web application to stop user from opening multiple browser window/tabs interacting with the system, which could cause serious concurrency problem if multi-conversation is not supported (This could happen if you simple store NHibernate Session in HttpSession to support long Session).<br />&lt;h4&gt;&lt;strong&gt;Short Burrow Conversation&lt;/strong&gt;&lt;/h4&gt;By default, Burrow framework starts a conversation at the beginning of a request and commit/close it at the end of the request - we call it a short conversation. In terms of NH session management, it can be deemed as an implementation of the OpenSessionInView pattern, that is, one NHibernate session and one transaction per http request. This takes care of most business transactions that require only one http request, for example, modifying the customer information. Burrow takes care of this type of short conversation transparently - your code does not even need to be aware of Burrow Conversation.<br />&lt;h4&gt;&lt;strong&gt;Long Burrow Conversation&lt;/strong&gt;&lt;/h4&gt;If you need to have a long conversation, you need to know a little about the NHibernate.Burrow.IConversation interface. We are going to explain it here.&lt;br&gt;In the request that you are going to start a long conversation - for example when you start a checkout process - you need to ask the current Burrow Conversation to span. Here is how:<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #606060&quot;&gt;&nbsp;&nbsp; 1:&lt;/span&gt; &lt;span style=&quot;color: #008000&quot;&gt;//Get a facade instance of burrow, it&#39;s free&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #606060&quot;&gt;&nbsp;&nbsp; 2:&lt;/span&gt; BurrowFramework bf = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; BurrowFramework();&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #606060&quot;&gt;&nbsp;&nbsp; 3:&lt;/span&gt;&nbsp; &lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #606060&quot;&gt;&nbsp;&nbsp; 4:&lt;/span&gt; &lt;span style=&quot;color: #008000&quot;&gt;//ask the current IConversation to span with PostBacks&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #606060&quot;&gt;&nbsp;&nbsp; 5:&lt;/span&gt; bf.CurrentConversation.SpanWithPostBacks(TransactionStrategy.BusinessTransaction);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;bf.CurrentConversation gives you the current IConversation (the interface represents Burrow Conversation) you are in. It was a short conversation before. IConversation.SpanWithPostBacks() tells the conversation to span with the post backs of a form. Now it becomes a long conversation. In pages that have only one form, this means that the conversation will be spanning as long as the user stays in the same page - the following postback requests will be using the same IConversation as this one. If the user goes to another page or close the current browser window/tab, the conversation will be discarded (If you need the conversation to span to another page, &lt;a href=&quot;http://nhcontrib.wiki.sourceforge.net/BurrowConversationExplained#SpanByUrl&quot;&gt;click here&lt;/a&gt;).&lt;br&gt;After the long business transaction is done - for example, the user finally confirmed the placement of the order in the checkout - you need to tell the Long Conversation to stop spanning (BTW, it&#39;s not needed for short conversation). Here is how:<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;bf.CurrentConversation.FinishSpan(); // note: bf &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; the BurrowFramework instance. you can create it anywhere.&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Burrow will commit the conversation at the end of this request - it will close the conversation. The next request will be assigned with a new conversation.&lt;br&gt;Also, you can cancel the conversation in the middle of it - for example user clicks the cancel button or something goes wrong. Here is how:<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;bf.CurrentConversation.GiveUp(); // note: bf &lt;span style=&quot;color: #0000ff&quot;&gt;is&lt;/span&gt; the BurrowFramework instance. you can create it anywhere.&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;<br />&lt;p&gt;The conversation won&#39;t be discarded immediately, but Burrow will rollback the transaction and close the conversation at the end of this request. This way all the data changes in this conversation won&#39;t be committed to database, but you can still read data from Database in this request - for example to display some user friendly error message. If something quite fatal happens and you really want to immediately cancel the current conversation, you can either throw an exception or do the following:&lt;/p&gt;<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;bf.CurrentConversation.GiveUp(); &lt;span style=&quot;color: #008000&quot;&gt;// note: bf is the BurrowFramework instance. you can create it anywhere.&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;bf.CloseWorkSpace();&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;<br />&lt;p&gt;After you called bf.CloseWorkSpace(), you&#39;ll probably need to immediately redirect to another page as Burrow managed services are no longer available for this request.&lt;/p&gt;<br />&lt;h4&gt;Transaction Strategy in Conversation&lt;/h4&gt;&lt;br&gt;I know you must have noticed the TransactionStrategy parameter we passed to SpanWithPostBacks() method, this parameter tells Burrow how to manage transactions for this long conversation. There are three of them for you to choose.<br />&lt;ul&gt;<br />&lt;li&gt;By default, that is, if you don&#39;t pass a TransactionStrategy to the method, Burrow will use one transaction per request pattern - it opens the transaction at the beginning of the request and commit it at the end of the request, which means that the long conversation is break into multiple atomic transactions, data change will be updated to DB on every request! <br />&lt;li&gt;&lt;strong&gt;TransactionStrategy.LongDBTransaction&lt;/strong&gt; - I know some people will need a long atomic conversation for some business transaction such as the example we just gave. If you pass this strategy to the method, Burrow will open keep the DB transaction alive until the conversation ends. Now the data changes will only get updated to DB after the whole long conversation is successfully finished. The long conversation is atomic now. However, the bad news is that now Burrow has to keep a long DB transaction and connection for this long conversation over multiple requests, even when user is thinking or wonders away. Fortunately we have the last strategy. <br />&lt;li&gt;&lt;strong&gt;TransactionStrategy.BusinessTransaction&lt;/strong&gt; - this strategy is the recommended one if you need an atomic but long conversation. This strategy will still use the one db transaction per request pattern - as in the default strategy. But, it will turn the NHibernate .Session.FlushMode to Never, and only flush the session when the conversation ends (or when you specifically command to flush session). This way, data change won&#39;t get updated to DB until the end of the long conversation. The conversation is atomic again. There is one issue here though, you lost the auto session flush feature NHibernate provides, one consequence will be that if you make some data change, it may not reflect in the query results later in the same long conversation. &lt;/li&gt;&lt;/ul&gt;Other than these three transaction strategies, you can set Burrow to leave the transaction to your own management, that is Burrow will no longer manage the transaction, you can and need to use BurrowFramework.CurrentConversation.TransactionManager to manage it. To use manual transaction management, set manualTransactionManagement=&quot;true&quot; in the NHibernate.Burrow Section<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;NHibernate.Burrow&lt;/span&gt;&nbsp; manualTransactionManagement=&quot;true&quot; &lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&nbsp;&nbsp;&nbsp; ...&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: #800000&quot;&gt;NHibernate.Burrow&lt;/span&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br&gt;That is the handling for most long conversation scenarios. The following are a couple of special cases:&lt;br&gt;&lt;a name=&quot;SpanByUrl&quot;&gt;&lt;/a&gt;&lt;strong&gt;Span by URL&lt;/strong&gt;&lt;br&gt;If you need the long conversation to span to another page, you still call SpanWithPostBack() method, but then you&#39;ll need to wrap the url of that page with conversation information so that Burrow will pick up the conversation for it. Here is how:<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;WebUtil wu = &lt;span style=&quot;color: #0000ff&quot;&gt;new&lt;/span&gt; WebUtil();&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #008000&quot;&gt;//use the following url instead of &quot;~/anotherPage.aspx&quot;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;string&lt;/span&gt; urlToAnotherPage = wu.WrapUrlWithConversationInfo(&lt;span style=&quot;color: #006080&quot;&gt;&quot;~/anotherPage.aspx&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;If you need a link on your page, you can either use this API to wrap the link, or you can use the NHibernate.Burrow.WebUtil.Controls.BurrowLink control. It inherits from HyperLink so you can use it exactly the same as HyperLink but it will automatically wrap the conversation information for you.&lt;br&gt;&lt;a name=&quot;SpanByCookie&quot;&gt;&lt;/a&gt;&lt;strong&gt;Span by Cookie&lt;/strong&gt;&lt;br&gt;Another way to span a conversation is IConverastion.SpanWithCookie(string workSpaceName); This will store the conversation information into browser cookies. However not all pages that picks up that cookie will pick up that conversation, which is unmanageable and dangerous. The concept WorkSpaceName is introduced to help here. You can group your HttpHandlers using this WorkSpaceName - HttpHandlers defined with the same WorkSpaceName can be deemed as being in the same WorkSpace. When you call CurrentConversation.SpanWithCookie(string workSpaceName) only the HttpHandlers defined with the same workSpaceName will be sharing that conversation. Here is an example of how it works:&lt;br&gt;Define the WorkSpaceName for APageInWorkSpaceA.aspx:&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;[NHibernate.Burrow.WebUtil.Attributes.WorkSpaceInfo(&lt;span style=&quot;color: #006080&quot;&gt;&quot;WorkSpace1&quot;&lt;/span&gt;)] &lt;span style=&quot;color: #008000&quot;&gt;//Define the page&#39;s workspace using Attribute&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;partial&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;class&lt;/span&gt; SharingConversations_Step06b : System.Web.UI.Page&lt;/pre&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;{}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Start spanning in another page:<br />&lt;div style=&quot;border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px&quot;&gt;<br />&lt;div style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none&quot;&gt;&lt;pre style=&quot;padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none&quot;&gt;bf.CurrentConversation.SpanWithCookie(&lt;span style=&quot;color: #006080&quot;&gt;&quot;WorkSpace1&quot;&lt;/span&gt;);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Now if user opens APageInWorkSpaceA.aspx in the same browser session, the request will be using the same conversation. As for Finish or GiveUp, there is no difference from long conversation spanning with postbacks.&lt;br&gt;If attribute is not enough for defining page&#39;s workSpaceName, as it&#39;s static, you can create your own Handler-WorkSpace management mechanism and implement the IWorkSpaceNameSniffer interface in Web.Util, that interface is in charge of getting the WorkSpaceName of an IHttpHandler. You can set in the Burrow Configuration the type of implementation of that interface the system should use ( Please look at NHibernate.Burrow.IBurrowConfig ).</p>