<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Client-Server|Reference Cache In Client-Server Mode" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem"> <head><title>Refreshing Objects</title> <script type="text/javascript">/* <![CDATA[ */ window.onload = function(){ var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf'; ZeroClipboard.setMoviePath(pathToFlash); function bindToClipBord(element,content){ var clip = new ZeroClipboard.Client(); clip.setText(content); clip.glue(element); }; if(location.protocol==='file:'){ $('.copylink-marker').remove(); } else{ $('.copylink-marker').each(function(){ var text = $(this).parent().parent().children('.prettyprint').html(); $(this).hover(function(){ bindToClipBord(this,text); }, function(){}); }); } prettyPrint(); }; /* ]]> */</script> <link href="../SkinSupport/MadCap.css" rel="stylesheet" /> <link href="../Resources/TableStyles/Basic.css" rel="stylesheet" /> <link href="../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" /> <script src="../Resources/Code/prettify.js"> </script> <script src="../Resources/Code/lang-vb.js"> </script> <script src="../Resources/Code/jquery.min.js"> </script> <script src="../Resources/Code/ZeroClipboard.js"> </script> <script src="../SkinSupport/MadCapAll.js" type="text/javascript"> </script> </head> <body> <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../index_CSH.html#client-server/refreshing_objects.htm" style="">Open topic with navigation</a> </p> <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../client-server.htm">Client-Server</a><span class="MCBreadcrumbsDivider"> > </span><a class="MCBreadcrumbsLink" href="reference_cache_in_client-server_mode.htm">Reference Cache In Client-Server Mode</a><span class="MCBreadcrumbsDivider"> > </span><span class="MCBreadcrumbs">Refreshing Objects</span> </div> <p> <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">'); document.write("Direct Link"); document.write('</a>');/*]]>*/</script> </p> <p> </p> <h1>Refreshing Objects</h1> <p>When working with multiple client object-containers each container has its own reference cache. When you query for objects, you get always the cached objects. This means, that objects probably have been updated in the mean-time but the client still sees the old state.</p> <p>For some scenarios you might need to refresh to objects to bring it up to date. There are two strategies for this. You can explicit refresh a object at any time. Or you can use callbacks to refresh object on each commit. Both methods have their advantage.</p> <table style="width: 100%;mc-table-style: url('../Resources/TableStyles/Basic.css');" class="TableStyle_Basic" cellspacing="0"> <col style="width: 10%;" /> <col style="width: 40%;" /> <col style="width: 40%;" /> <tbody> <tr> <td class="TableStyle_Basic_Body_0_0_RowSep_ColSep"> </td> <td class="TableStyle_Basic_Body_0_0_RowSep_ColSep">Explicit Refreshing</td> <td class="TableStyle_Basic_Body_0_0_RowSep_ColEnd">Using Callbacks</td> </tr> <tr> <td class="TableStyle_Basic_Body_0_0_RowSep_ColSep">Advantage</td> <td class="TableStyle_Basic_Body_0_0_RowSep_ColSep"> <ul> <li value="1">Selective refreshing possible, which reduces network traffic.</li> <li value="2">Can decide when a refresh is required. If no refresh is required, you can save the network traffic.</li> </ul> </td> <td class="TableStyle_Basic_Body_0_0_RowSep_ColEnd"> <ul> <li value="1">The objects are always up to date. </li> <li value="2">There's no need to explicitly refresh-calls in your data-access layer.</li> </ul> </td> </tr> <tr> <td class="TableStyle_Basic_Body_0_0_RowEnd_ColSep">Disadvantage</td> <td class="TableStyle_Basic_Body_0_0_RowEnd_ColSep"> <ul> <li value="1">Partial refreshed objects may lead to a inconsistent object-graph.</li> <li value="2">Probably a lot of refresh-calls spread over the code-base.</li> </ul> </td> <td class="TableStyle_Basic_Body_0_0_RowEnd_ColEnd"> <ul> <li value="1">A lot of network traffic is required to send the committing-events and object to the clients.</li> </ul> </td> </tr> </tbody> </table> <h2>Explicitly Refreshing Objects </h2> <p>You can refresh objects with the refresh-method on the object-container. The pass the object to refresh and the refresh-depth to the method:</p> <div class="codesnippet" MadCap:conditions="Primary.c#"> <pre class="prettyprint" xml:space="preserve">db.Ext().Refresh(objToRefresh, int.MaxValue);</pre> <div class="codesnippet-meta">RefreshingObjects.cs: refresh a object <div class="codedownload"><a href="../CodeExamples/clientserver/refresh/Example-clientserver-refresh-csharp.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div> </div> <div class="codesnippet" MadCap:conditions="Primary.VB.NET"> <pre class="prettyprint lang-vb" MadCap:conditions="Primary.Online" xml:space="preserve">db.Ext().Refresh(objToRefresh, Integer.MaxValue)</pre> <div class="codesnippet-meta">RefreshingObjects.vb: refresh a object <div class="codedownload"><a href="../CodeExamples/clientserver/refresh/Example-clientserver-refresh-vb.zip" class="codedownload" MadCap:conditions="Primary.Online">Download Code</a></div><div class="codedownload copylink-marker" MadCap:conditions="Primary.Online"><a href="#copy">Copy Code</a></div></div> </div> <h2>Using Callbacks For Refreshing Objects</h2> <p>You can use the committed-event to refresh objects as soon as another client commits. Take a look at the example: <a href="../advanced_topics/callbacks/possible_usecases/committed_event_example.htm" target="" title="" alt="" class="MCXref" xrefformat="See "{paratext}"">See "Committed Event Example"</a></p> <p> </p> <p> </p> <script type="text/javascript" src="../SkinSupport/MadCapBodyEnd.js"> </script> </body> </html>