<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>One Man went to Mow...</title>
	<atom:link href="http://onemanwenttomow.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://onemanwenttomow.wordpress.com</link>
	<description>...went to mow a meadow. One man's journey into uncharted territory.</description>
	<lastBuildDate>Wed, 21 Dec 2011 14:48:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='onemanwenttomow.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>One Man went to Mow...</title>
		<link>http://onemanwenttomow.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://onemanwenttomow.wordpress.com/osd.xml" title="One Man went to Mow..." />
	<atom:link rel='hub' href='http://onemanwenttomow.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Implementing the RowViewModel &#8211; Part 2</title>
		<link>http://onemanwenttomow.wordpress.com/2011/03/04/implementing-the-rowviewmodel-part-2/</link>
		<comments>http://onemanwenttomow.wordpress.com/2011/03/04/implementing-the-rowviewmodel-part-2/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 17:18:46 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[RowViewModel]]></category>
		<category><![CDATA[Silverlight Development]]></category>

		<guid isPermaLink="false">https://onemanwenttomow.wordpress.com/2011/03/04/implementing-the-rowviewmodel-part-2/</guid>
		<description><![CDATA[Part 2 – Getting Data into the Grid In Part 1, we setup the projects necessary for a standard business application using IdeaBlade DevForce for the Model, MVVM Light for the ModelView and a Telerik RadGridView in the View. In Part 3, we will follow through the binding process to see some of the challenges [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=331&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p></p>
<h1>Part 2 – Getting Data into the Grid</h1>
<p>In <a href="http://onemanwenttomow.wordpress.com/2011/03/03/implementing-the-rowviewmodel/">Part 1</a>, we setup the projects necessary for a standard business application using IdeaBlade DevForce for the Model, MVVM Light for the ModelView and a Telerik RadGridView in the View.</p>
<p>In Part 3, we will follow through the binding process to see some of the challenges posed when making the grid editable.</p>
<p>In Part 2, we will make the changes necessary to make the grid editable.</p>
<h3>Requirements</h3>
<p>For this part of the sample, the requirements are as follows:</p>
<ol>
<li>Show Orders in the Rows of the Grid.</li>
<li>Make the Grid Editable.</li>
<li>Save changes to the Orders with a Save Changes button.</li>
</ol>
<h3>Showing the Orders in the Grid</h3>
<p>This will require adding an Orders property to the MainViewModel; populating that property and then binding the Orders property to the grid.</p>
<ol>
<li>Make sure there is a reference in the Web project to the server-side Model project.</li>
<li>Open the MainViewModel.cs file.</li>
<li>Remove the Welcome property.</li>
<li>Open the ViewModel\MainViewModel.cs file.</li>
<li>Use the mvvminpc Snippet to add an Orders property.<br />
<pre class="brush: csharp;">/// &lt;summary&gt;
/// The &lt;see cref=&quot;Orders&quot; /&gt; property's name.
/// &lt;/summary&gt;
public const string OrdersPropertyName = &quot;Orders&quot;;

private ObservableCollection&lt;order&gt; _orders;

/// &lt;summary&gt;
/// Gets the Orders property.
/// TODO Update documentation:
/// Changes to that property's value raise the PropertyChanged event. 
/// This property's value is broadcasted by the Messenger's default instance when it changes.
/// &lt;/summary&gt;
public ObservableCollection&lt;order&gt; Orders
{
    get
    {
        return _orders;
    }

    set
    {
        if (_orders == value)
        {
            return;
        }

        //var oldValue = _orders;
        _orders = value;

        // Remove one of the two calls below
        //throw new NotImplementedException();

        // Update bindings, no broadcast
        RaisePropertyChanged(OrdersPropertyName);

        // Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
        //RaisePropertyChanged(OrdersPropertyName, oldValue, value, true);
    }
}</pre></li>
<li>Next, add a method to fill the collection. <pre class="brush: csharp;">private void GetOrdersAsync()
{
    var em = new NorthwindIBEntities();
    var qry = em.Orders;
    em.ExecuteQueryAsync(qry, args =&gt;
         this.Orders = new ObservableCollection&lt;order&gt;(args.Results));
}</pre></li>
<li>Next, add a call to the new method in MainViewModel constructor:<br />
<pre class="brush: csharp;">public MainViewModel() 
{ 
    GetOrdersAsync();</pre></li>
<li>Finally, add a binding to the XAML to show the Orders in the Grid.  (Set the ItemsSource of the RadGridView to Orders.)<br />
<pre class="brush: xml;">&lt;telerik:RadGridView Name=&quot;radGridView1&quot; ItemsSource=&quot;{Binding Path=Orders}&quot; Height=&quot;775&quot; Width=&quot;1000&quot; /&gt;</pre></li>
<li>Build and Run.  After a moment or two, you should see the grid, fully populated with Orders.<br />
<a href="http://onemanwenttomow.files.wordpress.com/2011/03/image25.png"><img style="display:inline;border-width:0;" title="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb22.png?w=244&#038;h=182" border="0" alt="image" width="244" height="182" /></a></li>
</ol>
<h2>Making the Grid Editable</h2>
<p>For once, the default behavior is desirable.  We get this for free because the RadGridView is editable by default.  Due to the magic of Binding, the Order objects are getting updated whenever a cell in the grid is edited.</p>
<h2>Saving the Changes</h2>
<p>Saving those changes will require us to have a button bound to an ICommand that will tell the EntityManager to save all the changes.</p>
<ol>
<li>In MainPage.xaml, add a button to the StackPanel above (or below) the RadGridView.<br />
<pre class="brush: xml;">&lt;Button Content=&quot;Save&quot; Height=&quot;23&quot; Name=&quot;SaveAllButton&quot; Width=&quot;75&quot; HorizontalAlignment=&quot;Left&quot; /&gt;</pre></li>
<li>In MainViewModel.cs, add a new RelayCommand named SaveAllCommand.<br />
<pre class="brush: csharp;">public RelayCommand SaveAllCommand
{
    get;
	private set;
}</pre></li>
<li>In the MainViewModel constructor, add a line to instantiate the command:<br />
<pre class="brush: csharp;">SaveAllCommand = new RelayCommand(this.SaveAllOrders);</pre></li>
<li>Now add the SaveAllOrders method and the SaveAllButtonEnabled property:<br />
<pre class="brush: csharp;">private void SaveAllOrders()
{
    this.SaveAllButtonEnabled = false;
    _entityManager.SaveChangesAsync(args =&gt; 
        this.SaveAllButtonEnabled = true);
}

public bool SaveAllButtonEnabled
{
    get
    {
        return _saveAllButtonEnabled;
    }
    set
    {
        _saveAllButtonEnabled = value;
        RaisePropertyChanged(&quot;SaveAllButtonEnabled&quot;);
    }
}</pre></li>
<li>Now you can go back to the button to set the bindings:<br />
<pre class="brush: xml;">&lt;Button Content=&quot;Save&quot; Height=&quot;23&quot; Name=&quot;SaveAllButton&quot; Width=&quot;75&quot; HorizontalAlignment=&quot;Left&quot; IsEnabled=&quot;{Binding Path=SaveAllButtonEnabled}&quot; Command=&quot;{Binding Path=SaveAllCommand}&quot; /&gt;</pre></li>
<li>Build and Run.  After a moment or two, you should see the grid, fully populated with Orders.  Try editing some of the orders and hit Save All.  Refresh the page to see that the changes were saved.</li>
</ol>
<h3>What&#8217;s next?</h3>
<p>So now you have an editable grid.  So far, we have not needed the RowViewModel.  If you only want SaveAll functionality, the default behavior of the grid will suffice.  The grid lets you edit any cell all the time and the bindings keep the model up to date.  A simple call to entity manager to save the changes and all is well.<br />
However, if you want some entity specific functionality, you will find it quite cumbersome to try to deal with this within the context of the grid&#8217;s ViewModel as it is really only concerned with the grid and entire grid related actions (such as Save All).</p>
<p>In Part 3, we will add some entity specific requirements so we can see how to use the RowViewModel to make working with the entities in the grid much simpler.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/331/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=331&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2011/03/04/implementing-the-rowviewmodel-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb22.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementing the RowViewModel &#8211; Part 1</title>
		<link>http://onemanwenttomow.wordpress.com/2011/03/03/implementing-the-rowviewmodel/</link>
		<comments>http://onemanwenttomow.wordpress.com/2011/03/03/implementing-the-rowviewmodel/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 04:00:00 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[RowViewModel]]></category>
		<category><![CDATA[Silverlight Development]]></category>

		<guid isPermaLink="false">https://onemanwenttomow.wordpress.com/2011/03/03/implementing-the-rowviewmodel/</guid>
		<description><![CDATA[&#160; Part 1 – Setting up the Projects In my earlier post here, I introduced the concept of a RowViewModel to make editable grids using the MVVM pattern.&#160; In this post, I will demonstrate how to implement the RowViewModel using a combination of IdeaBlade DevForce for the Model, MVVMLite for ViewModel support and Telerik’s Silverlight [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=281&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>&nbsp;</h1>
<h1>Part 1 – Setting up the Projects</h1>
<p>In my earlier post <a title="MVVM and the Editable Grid" href="http://onemanwenttomow.wordpress.com/2010/10/08/mvvm-and-the-editable-grid/">here</a>, I introduced the concept of a RowViewModel to make editable grids using the MVVM pattern.&nbsp; In this post, I will demonstrate how to implement the RowViewModel using a combination of IdeaBlade DevForce for the Model, MVVMLite for ViewModel support and Telerik’s Silverlight RadGridView for the View.</p>
<h3>Prerequisites:</h3>
<ol>
<li><a href="http://www.ideablade.com/DevForceUniversal/DevForceUniversal_DownloadEditions.aspx">IdeaBlade DevForce</a> 6.0.7 or later.
<li><a href="http://www.telerik.com/download.aspx">Telerik Silverlight Controls</a> 2010.3 or later.
<li><a href="http://mvvmlight.codeplex.com/">MVVM Light Toolkit</a>
<li><a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx">VisualStudio 2010</a> and <a href="http://www.silverlight.net/getstarted/">Silverlight 4</a>
<li><a href="http://silverlight.codeplex.com/releases">Silverlight 4 Toolkit</a> </li>
</ol>
<h3>Assumptions:</h3>
<ol>
<li>We’ll use IdeaBlade’s sample database:&nbsp; NorthwindIB.&nbsp; This can be found in the \Program Files\DevForce 2010\ folder.
<li>I have way too many VS add-ins installed so my screen shots may not appear as your screen does.
<li>I do use JetBrains Resharper and Telerik’s JustCode, so some of the refactorings and shortcuts may not be available if you do not have these tools. </li>
</ol>
<h3>Creating the Beginning State</h3>
<ol>
<li>Per the article and sample shown at <a href="http://drc.ideablade.com/xwiki/bin/view/Documentation/MVVM-Light-DevForce">MVVM Light with DevForce</a>, we will create a sample app using the MVVM Light SL4 template.&nbsp; (I.e. Set up their MvvmLite1 example.) <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image14.png"><img title="image" style="display:inline;border-width:0;" height="306" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb14.png?w=644&#038;h=306" width="644" border="0"></a>
<li>Then add the DevForce Silverlight Application project. <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image31.png"><img title="image" style="display:inline;border-width:0;" height="306" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image3_thumb.png?w=644&#038;h=306" width="644" border="0"></a>
<li>Delete the README_FIRST files.
<li>In the Model project:
<ol>
<li>Delete App.xaml and MainPage.xaml.
<li>Rename the project with SL suffix.&nbsp; Do not rename the Assembly with the SL suffix and do not change the namespace. </li>
</ol>
<li>In the Application project:
<ol>
<li>Add a reference to the Model project.
<li>Add references to the DevForce assemblies referenced in the Model project. <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image4.png"><img title="image" style="display:inline;border-width:0;" height="120" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb4.png?w=212&#038;h=120" width="212" border="0"></a>
<li>In the properties for the DevForce assemblies, change the Copy Local to True and the Specific Version to False. <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image121.png"><img title="image" style="display:inline;border-width:0;" height="228" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image12_thumb.png?w=253&#038;h=228" width="253" border="0"></a>
<li>Add a reference to System.Runtime.Serialization. </li>
</ol>
<li>In the Web project:
<ol>
<li>Rename the web project to remove the word Model.
<li>In the project properties:
<ol>
<li>Rename the Assembly and the namespace.
<li>On the Silverlight Applications tab, remove the dead DevForce Silverlight app project (if present). <br />Add the Silverlight Application (e.g. RVMSample).&nbsp; </li>
</ol>
<li>Delete the test HTML page and the Default.aspx page.
<li>Set the Web project as the Startup Project.&nbsp;
<li>Set the new test ASPX page as the Start Page.
<li>Delete the XAP file from the ClientBin folder. </li>
</ol>
<li>Save and Close the solution.
<li>Rename the project folders to match the project names.
<li>Edit the .SLN file in a text editor to correct the folder names there too.&nbsp; <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image22.png"><img title="image" style="display:inline;border-width:0;" height="158" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb20.png?w=244&#038;h=158" width="244" border="0"></a>
<li>Open the solution in VS.
<li>Build and Run.&nbsp; Nothing so far has changed the functionality so it should work fine:&nbsp;&nbsp;&nbsp; <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image23.png"><img title="image" style="display:inline;border-width:0;" height="98" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb21.png?w=244&#038;h=98" width="244" border="0"></a>&nbsp;&nbsp;&nbsp;&nbsp; </li>
</ol>
<h3>Creating the Server-Side Model Project</h3>
<p>So far so good.&nbsp; We have setup the three-project solution.&nbsp; Unfortunately, this means we’re going to load the EDMX into the Web project, which hardly seems fitting.&nbsp; Let’s create a server-side project to house the server side Model.</p>
<ol>
<li>Add a regular Class Library project as the server side Model.&nbsp; This should be named <em>application</em>.Model.
<li>Delete Class1.
<li>In the Web project, add a reference to the <em>application</em>.Model project.
<li>Add an ADO.Net Entity Data Model name it <strong>NorthwindIBModel</strong>.
<li>Select to Generate from database.
<li>Connect to the NorthwindIB database.
<li>Select the following tables: <br />Customer <br />Employee <br />Order <br />OrderDetail <br />Product
<li>Change the namespace to <em>application</em>.Model.
<li>Wait while the Entity Manager and IdeaBlade do their code generation.&nbsp; IdeaBlade will also make a link from the Model.SL project to the Model project so they share code.
<li>Copy the new connectionString settings from app.config in this project to web.config in the web project.
<li>Build the solution to make sure all the references are configured properly.&nbsp; Run the app.&nbsp; See nothing has changed yet. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </li>
</ol>
<h3>Adding the Grid to the View</h3>
<p>Great, now we have client-side (Model.SL) and server-side (Model) model projects, a Silverlight application project and a Web project to host it all in.&nbsp; Let’s go ahead and add the Telerik Grid to the project, then we can finally start looking at the Row-View-Model pattern.</p>
<ol>
<li>In the <em>application</em> project, open the MainPage.xaml.
<li>Change the Width and Height of the page to 1000 x 800.
<li>Remove the TextBlock that is there.
<li>Change the &lt;Grid&gt; to a &lt;StackPanel&gt;.
<li>In the &lt;StackPanel&gt;, drag and drop a Telerik RadGridView from the Toolbox.
<li>Change the Width and Height of the RadGridView to 1000 x 800.
<li>Build the solution to make sure all the references are configured properly.
<li>Run the application.&nbsp; You should see the empty Telerik grid in your browser: <br /><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image16.png"><img title="image" style="display:inline;border-width:0;" height="426" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb16.png?w=605&#038;h=426" width="605" border="0"></a> </li>
</ol>
<p>Ta da!&nbsp; All that work to set up the beginning state for exploring RVM.&nbsp; In my next posting, you will get the requirements for the grid and see how we can use the RowViewModel to make in-line grid editing much simpler.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/281/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/281/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/281/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=281&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2011/03/03/implementing-the-rowviewmodel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image3_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image12_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb20.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb21.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb16.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>webMethods pub.db:call Examples</title>
		<link>http://onemanwenttomow.wordpress.com/2011/02/17/webmethods-pub-dbcall-examples/</link>
		<comments>http://onemanwenttomow.wordpress.com/2011/02/17/webmethods-pub-dbcall-examples/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 17:53:04 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[webMethods]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[pub.db:call]]></category>

		<guid isPermaLink="false">https://onemanwenttomow.wordpress.com/2011/02/17/webmethods-pub-dbcall-examples/</guid>
		<description><![CDATA[I cannot find any examples of the mappings needed to use the pub.db:call in webMethods 8.0.1.&#160; The documentation is helpful, but is barren of any examples.&#160; Basically the provided documentation defines little more than name, rank, serial number and description of each built-in service.&#160; In the absence of any examples, in the documentation or anywhere [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=254&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I cannot find any examples of the mappings needed to use the pub.db:call in webMethods 8.0.1.&#160; The documentation is helpful, but is barren of any examples.&#160; Basically the provided documentation defines little more than name, rank, serial number and description of each built-in service.&#160; In the absence of any examples, in the documentation or anywhere else on the web, here is my humble attempt at providing some help.</p>
<h3>Example 1:&#160; A procedure with a single IN parameter.</h3>
<p>I have a stored procedure inside a package in Oracle 10 with this signature:&#160; </p>
<p>CREATE OR REPLACE PACKAGE PKG_EDI_FUNCTIONS AS</p>
<p>&#160;&#160;&#160; PROCEDURE APPLY_BUS_RULES_TO_RAWDATA (    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; inGcsControlNumber VARCHAR2     <br />&#160;&#160;&#160; );</p>
<p>END;</p>
<p>In a MAP flow step, I have mapped the <em>ControlNumber</em> variable shown on the left to the <em>data/inGcsControlNumber</em> variable defined on the right.&#160; </p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image17.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="321" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb17.png?w=599&#038;h=321" width="599" border="0" /></a> </p>
<p><em>data</em> is defined as shown:</p>
<table cellspacing="0" cellpadding="2" width="548" border="1">
<tbody>
<tr>
<td valign="top" width="196">data</td>
<td valign="top" width="103">Document</td>
<td valign="top" width="305">&#160;</td>
</tr>
<tr>
<td valign="top" width="196">&#160;&#160;&#160;&#160;&#160;&#160;&#160; inGcsControlNumber</td>
<td valign="top" width="103">String</td>
<td valign="top" width="305">maps to ControlNumber variable</td>
</tr>
</tbody>
</table>
<p>In the <strong><em>pub.db:call</em></strong> flow step, I need to configure the <strong><em>call</em></strong> as follows: </p>
<table cellspacing="0" cellpadding="2" width="549" border="1">
<tbody>
<tr>
<td valign="top" width="200">$dbAlias</td>
<td valign="top" width="347">myDbAlias</td>
</tr>
<tr>
<td valign="top" width="200">$dbProc</td>
<td valign="top" width="347">PKG_EDI_FUNCTIONS.APPLY_BUS_RULES_TO_RAWDATA</td>
</tr>
<tr>
<td valign="top" width="200">$dbProcSig</td>
<td valign="top" width="347"><em>See below</em></td>
</tr>
<tr>
<td valign="top" width="200">$dbParamsByOrder</td>
<td valign="top" width="347">true</td>
</tr>
<tr>
<td valign="top" width="200">$data</td>
<td valign="top" width="347"><em>data</em> document from above</td>
</tr>
</tbody>
</table>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image32.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="372" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image3_thumb1.png?w=433&#038;h=372" width="433" border="0" /></a> </p>
<p>To configure the <strong><em>$dbProcSig</em></strong>, follow these steps:</p>
<p>1) Right click on $dbProcSig and choose Set Value…</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image122.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="259" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image12_thumb1.png?w=250&#038;h=259" width="250" border="0" /></a> </p>
<p>2) In the dialog that follows, click the Add button to add a row:</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image62.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="269" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image6_thumb1.png?w=578&#038;h=269" width="578" border="0" /></a> </p>
<p>3)&#160; In the next dialog, enter the parameter definition, like so:</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image92.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="222" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image9_thumb1.png?w=404&#038;h=222" width="404" border="0" /></a> </p>
<p>4) Click OK to close the dialogs.&#160; You now have the parameter defined for the procedure.</p>
<p>That’s it.&#160; The call is defined and should execute as desired.</p>
<h3>Example 2:&#160; A procedure with IN and OUT parameters.&#160; </h3>
<p>I have a procedure with several OUT parameters that I want to call.&#160; I then want to use the values of those parameters in an email sent by webMethods. </p>
<p>Here is the procedure’s signature:</p>
<p>PROCEDURE LOAD_MEASUREMENT (    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; inGcsControlNumber VARCHAR,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; outRowCounter OUT NUMBER,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; outErrorCounter OUT NUMBER,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; outAccumulatedErrorMsg OUT VARCHAR2     <br />&#160;&#160;&#160; );</p>
<p>In a MAP flow step, prior to the db:call step, I set up the <strong><em>$data</em></strong> exactly as shown above in Example 1.&#160; You only need to supply variables for the IN and INOUT parameters – do not supply values for the OUT parameters.</p>
<p>In the $dbProcSig, following the same process as in Example 1, I add four parameter definitions, like so:</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image211.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="269" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image21_thumb1.png?w=578&#038;h=269" width="578" border="0" /></a> </p>
<p>So the Map step looks like this:</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image18.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="325" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image18_thumb.png?w=461&#038;h=325" width="461" border="0" /></a> </p>
</p>
</p>
</p>
</p>
<p>Now, that’s it.&#160; The procedure is defined and should execute as expected.&#160; However, we’re not done yet.&#160; Where did the OUT values go?&#160; </p>
<p><strong>Getting at the OUT parameter values</strong></p>
<p>It turns out that at run time, WM puts the OUT parameters in the Pipeline.&#160; In this case, you will find <strong><em>outRowCounter</em></strong>, <strong><em>outErrorCounter</em></strong> and <strong><em>outAccumulatedErrorMsg</em></strong> in the Pipeline.</p>
<p>You can get to these in a MAP step, but there’s a little trick to doing so.&#160; Try this:</p>
<p>1) After your <strong>db:call</strong> step, create a MAP step.&#160; </p>
<p>2) In the Output channel of that MAP step, create a new String variable, name it something like the first OUT parameter.&#160; In my case, I chose <strong><em>returnedRowCounter</em></strong>.&#160; Repeating for each OUT parameter, I added <strong><em>returnedErrorCounter</em></strong> and <strong><em>returnedErrorMsg</em></strong>.</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image241.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="253" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image24_thumb1.png?w=214&#038;h=253" width="214" border="0" /></a> </p>
<p>3) For each variable I just defined, right click and choose Set Value…&#160; Set the value to the name of the OUT parameter, surrounded by %.&#160; Then check the Perform variable substitution box.&#160; Like this:</p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2011/03/image27.png"><img title="image" style="border-right:0;border-top:0;display:inline;border-left:0;border-bottom:0;" height="187" alt="image" src="http://onemanwenttomow.files.wordpress.com/2011/03/image27_thumb.png?w=404&#038;h=187" width="404" border="0" /></a> </p>
</p>
<p>Now, the OUT parameter values are available to you to do further processing in subsequent flow steps.</p>
<p>Ta da!</p>
<p>Hopefully, this will help save someone a week of emails with softwareAG tech support.&#160; They did, eventually, help me sort it out, and Deepa gets kudos for putting up with my nagging and for helping the blind to see.&#160; Thanks.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=254&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2011/02/17/webmethods-pub-dbcall-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image_thumb17.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image3_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image12_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image6_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image9_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image21_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image18_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image24_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2011/03/image27_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>MVVM and the Editable Grid</title>
		<link>http://onemanwenttomow.wordpress.com/2010/10/08/mvvm-and-the-editable-grid/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/10/08/mvvm-and-the-editable-grid/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 20:24:50 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[MVVM]]></category>
		<category><![CDATA[RowViewModel]]></category>
		<category><![CDATA[Silverlight Development]]></category>

		<guid isPermaLink="false">https://onemanwenttomow.wordpress.com/2010/10/08/mvvm-and-the-editable-grid/</guid>
		<description><![CDATA[There is a dirty little secret in the Grid market:&#160; making a Grid Editable, on a row-by-row basis (not in its entirety), is a nightmare. So, as we all know, MVVM is the cure-all for everything UI, so apply MVVM to the Grid form and away we go.&#160; Right?&#160; Doh!&#160; Wrong. You see, hosting the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=229&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is a dirty little secret in the Grid market:&#160; making a Grid Editable, on a row-by-row basis (not in its entirety), is a nightmare.</p>
<p>So, as we all know, MVVM is the cure-all for everything UI, so apply MVVM to the Grid form and away we go.&#160; Right?&#160; </p>
<p>Doh!&#160; Wrong.</p>
<p>You see, hosting the Grid in the View of a form actually ends up making the hassle even worse.&#160; But do not despair, there is a simple-enough solution to this otherwise complex dilemmas.&#160;&#160; I call this solution:&#160; the RowViewModel.</p>
<p>The what you say?&#160; Heretical mishmash you say?&#160; Read on fearless coder, read on.</p>
<h3>Terminology</h3>
<p>First, let’s at least agree to some nomenclature.&#160; Failing that, here is MY understanding of MY use of these terms.</p>
<p><strong>View</strong> &#8211; An unintelligent skin hosting UI controls and bindings and minimal code to call Commands and raise Events.&#160; Can be injected into the View Model at run time. </p>
<p><strong>View Model</strong> &#8211; All the intelligence behind the View is stored here.&#160; This client side class defines and executes Commands and knows how to respond to events and manipulate UI controls and fields.&#160; This class will pass on all persistence methods to the repository class.&#160; The ViewModel holds a reference to an instance of the client side business object and wraps its properties in ViewModel properties for binding to the UI.&#160; The UI does not bind directly to the business object, but to the ViewModel property instead.&#160; For example, suppose you can&#8217;t save a customer until the Name, Phone and City are populated.&#160; The ViewModel owns the state of the Save button (enabled/disabled) and the validation flags for required fields.&#160; It makes sense to put a function in each property setter in the ViewModel for Name, Phone and City that will check whether to enable/disable save. </p>
<p><strong>Repository</strong> &#8211; A class that knows how to interact with your Data Layer and is responsible for dealing with the persistence methods provided in your ORM framework.&#160; (For example, DevForce has an EntityManager that has a Save method.&#160; The Repository is the only class that should ever call that Save method.) </p>
<p><strong>Business Object</strong> &#8211; In DevForce 3.5, there&#8217;s a client side Silverlight business class that is the synonym of the server-side data class. </p>
<p><strong>Data Object</strong> &#8211; In DevForce 3.5, the server-side C# version of the business object.&#160; These classes are generated by DevForce from the EntityFramework model.</p>
<h3>RowViewModel Conceptual Overview</h3>
<p>So here&#8217;s the application model for a UI Module with an editable grid.&#160; As an example, let’s imagine we want to provide an editable heirarchical grid with a list of customers in it and a list of their addresses nested underneath each customer row.</p>
<p>First, we need the View and ViewModel for the grid form.</p>
<p>&#160; 1.&#160; One View class for the page/tab/control that hosts the grid (e.g. CustomerGridView). </p>
<p>&#160; 2.&#160; One ViewModel class backing the page/tab/control that hosts the grid (e.g. CustomerGridViewModel). </p>
<p>The gridView and gridViewModel are responsible for managing interactions around the grid and for actions that affect multiple rows.&#160; For example, &quot;Select All&quot;, &quot;Print All&quot;, &quot;Expand All&quot;, &quot;Print Selected Customers&quot;, Filters of all sorts, column sorting, etc.</p>
<p>Second, we need:&#160; </p>
<p>&#160; 3.&#160; A RowViewModel class for each row type (e.g. CustomerRowViewModel, AddressRowViewModel). </p>
<p>The gridViewModel holds a collection of the top level &lt;parent&gt;RowViewModels (e.g. CustomerRowViewModels).&#160; Each top level RowViewModel holds a collection of &lt;child&gt;RowViewModels (e.g. AddressRowViewModels).</p>
<p>Lastly, there should be:</p>
<p>&#160; 4.&#160; One Repository class to support the functionality represented by the entire page.&#160; This repository is likely inherited from a utility class that provides all the standard repository behavior (persistence, querying, etc.) using generics. </p>
<p>Now that you have been introduced to these classes, here’s how they come together:</p>
<p>Say we have Customers and Addresses.    <br />The Grid itself will be configured as a hierarchical grid with one parent band and one child band.&#160; Where the parent shows each Customer as a row and each Address as a row underneath the Customer row.&#160; Traditionally, you would bind the parent row source to the Customers collection property of the gridViewModel, and the child row source to the Addresses property of the Customer object.</p>
<p>Now, imagine the user starts to edit a cell.&#160; Which cell?&#160; Well, the grid will tell you which cell.&#160; It’s the Customer Rep column for Row 17.&#160; Which customer is bound to Row 17?&#160; Some grids won’t tell you, so you have to jump through hoops to figure it out.&#160; And heaven forbid the grid is sortable because with one click, all your mappings are out of date.&#160; Meanwhile, back to the Customer Rep column.&#160; It’s bound to a combo box.&#160; You have three types of customers:&#160; Volume, Retail, and Educator.&#160; There are different Reps for each type.&#160; Uh-oh.&#160; Now you need, not just any combo box, but a filtered combo that is dependent on the Customer Type (which we’ll assume was selected earlier in the row).&#160; </p>
<p>If you use the Grid’s built-in combo box column type, it is bound to a collection of Customer Reps in the gridViewModel and you can watch as you filter that list and the grid blanks all the rows that have a value that is not in the filtered list.&#160; Yeuch.&#160; </p>
<p>Or you can try a hovering combo that comes to the exact co-ordinates of the cell and hovers above it providing the illusion that it is part of the grid, then you can populate it however you want.&#160; But wait, that means you now have to write all the code to get that combo to work, manage the binding to the instance you need, and get the whole thing to sync properly when you’re done editing it.&#160; Ack!&#160; Oh, and you can’t use the grid’s built-in undo feature any more.</p>
<h3>What to do?&#160; Enter the RowViewModel.</h3>
<p>Here’s how we bring the RowViewModel into this.</p>
<p>In the parent band, each grid row is a single View for a single RowViewmodel in the gridViewModel.CustomerRowViewModels collection.    <br />Each CustomerRowViewModel holds a collection of its own AddressRowViewModels.&#160; <br />The child bands (there is one child band for each parent band that has children), have rows, each row in a child band is a View for an AddressRowViewModel. </p>
<p>In this structure, the rows can be bound appropriately and each RowViewModel is responsible for the interactions with 1 and only 1 row in the grid.</p>
<p>Back to our Customer Rep combo box problem.&#160; Now, the CustomerReps collection is a property of the CustomerRowViewModel and the grid’s built-in combobox can be happily bound to the CustomerRowViewModel.CustomerReps collection without complaint.&#160; When the Customer Type changes, the CustomerReps collection is repopulated and the binding will update the combo box automagically.&#160; Yay. No code to translate from Cell to Customer and the tie-in from the CustomerGrid Column binding to the CustomerRowViewModel property is a very standard binding.</p>
<p>So how does this look in code?&#160; I’m going to have to get back to you on that as I put together the code example for this simple scenario.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/229/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=229&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/10/08/mvvm-and-the-editable-grid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>
	</item>
		<item>
		<title>Why can&#8217;t I debug into my Windows Workflow?</title>
		<link>http://onemanwenttomow.wordpress.com/2010/04/22/why-cant-i-debug-into-my-windows-workflow/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/04/22/why-cant-i-debug-into-my-windows-workflow/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:01:37 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Workflow]]></category>
		<category><![CDATA[breakpoint]]></category>
		<category><![CDATA[not hitting breakpoint]]></category>
		<category><![CDATA[timeout]]></category>
		<category><![CDATA[unable to debug]]></category>
		<category><![CDATA[waithandle]]></category>
		<category><![CDATA[workflowmanager]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/?p=219</guid>
		<description><![CDATA[I had a test project that I was using to Unit Test my Windows Workflow activities. Green across the board. I put all the activities together into a workflow and set up the test for the workflow, but the Output Parameters were always empty. I put breakpoints in the code. The debugger never stopped at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=219&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had a test project that I was using to Unit Test my Windows Workflow activities.  Green across the board.</p>
<p>I put all the activities together into a workflow and set up the test for the workflow, but the Output Parameters were always empty.  </p>
<p>I put breakpoints in the code.  The debugger never stopped at them.</p>
<p>I created a console app to host the workflow and made the EXE for the console the startup app for the workflow project.  Several sites said this would enable debugging inside the workflow.  Nope!  The debugger never stopped inside the workflow.</p>
<p>And the Workflow never terminated, or cancelled, in fact, it seemed to be dying and disappearing.  WTF!?!</p>
<p>After much anguish, I looked through every single method and property of my WorkflowManager class and my WorkflowWrapper class.  And then I saw it&#8230;</p>
<p>The WaitAll method in the Manager class sits around using the manual WaitHandles on the workflows it is managing.  When they all complete, the manager returns control to the calling code.</p>
<p>The unit test says:<br />
1) Set up the Manager<br />
2) Set up the Workflow<br />
3) WaitAll(5000)<br />
4) Assert.IsTrue(workflow.OutputParamaters.Count()&gt;0);</p>
<p>I finally (as in DOHN!) realized that the WaitAll method takes a timeout parameter that is in milliseconds.  Each activity was tested separately and could complete in less than 5s.  The entire workflow, however, needed more time.  The WaitAll was dumping out of the thread when the time limit was hit, disposing of the workflow runtime before it could complete and without raising ANY other events.  Grrrr&#8230;</p>
<p>So, now I have upped the wait time in my test to 120,000 (2 mins) and, lo and behold, the test passes.   Grrrr again&#8230;</p>
<p>So, just a little tip:</p>
<p>TIP:  When debugging workflows, make sure your WaitHandle timeout is set to longer than the combination of the time for the process to execute plus the time you will spend stepping through the debug code, otherwise, the WaitHandle will trigger and dump you out of the WorkflowRuntime before the Workflow actually gets a chance to finish.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=219&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/04/22/why-cant-i-debug-into-my-windows-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>
	</item>
		<item>
		<title>IdeaBlade DevForce – Model Setup Walk-through – Sample Code</title>
		<link>http://onemanwenttomow.wordpress.com/2010/04/06/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-sample-code/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/04/06/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-sample-code/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 15:39:22 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[DevArt dotConnect for Oracle]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Silverlight Development]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/?p=211</guid>
		<description><![CDATA[Attached here is the finished sample project, created by following the steps outlined in the IdeaBlade DevForce – Model Setup Walk-through: Background Step 1: The Entity Framework Project Step 2: The DevForce Projects Attached Code: Sample Code Notes: Of course I had to adjust the connection string in the ModelEF&#8217;s app.config file. The SQL to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=211&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Attached here is the finished sample project, created by following the steps outlined in the IdeaBlade DevForce – Model Setup Walk-through:<br />
<a href="http://onemanwenttomow.wordpress.com/2010/02/25/ideablade-devforce-model-setup-walk-through-background/">Background</a><br />
<a href="http://onemanwenttomow.wordpress.com/2010/03/02/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-1-the-entity-framework-project/">Step 1: The Entity Framework Project</a><br />
<a href="http://onemanwenttomow.wordpress.com/2010/03/04/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-2-the-devforce-projects/">Step 2: The DevForce Projects</a></p>
<p>Attached Code:  <a href="http://docs.google.com/leaf?id=0B8SbA2TVfaSmMDFhMzc3ZTEtM2FkMy00YzRlLWFkZjAtNmVmNGUzNmNiNDYx&amp;hl=en">Sample Code</a></p>
<p><em>Notes:</em><br />
Of course I had to adjust the connection string in the ModelEF&#8217;s app.config file.<br />
The SQL to create the tables is in the Step 1 instructions linked above.<br />
I have not included the DLL&#8217;s and Installs in the dependencies and installations folders.  These can be readily downloaded from the various vendors&#8217; sites.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=211&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/04/06/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-sample-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>
	</item>
		<item>
		<title>Configure the Key when using Views as the basis for Entities</title>
		<link>http://onemanwenttomow.wordpress.com/2010/03/25/configure-the-key-when-using-views-as-the-basis-for-entities/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/03/25/configure-the-key-when-using-views-as-the-basis-for-entities/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 15:43:02 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Entity Key]]></category>
		<category><![CDATA[Model Creation]]></category>
		<category><![CDATA[Select All]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[View-based Entity]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/?p=200</guid>
		<description><![CDATA[When using a View as the basis for an Entity in the Entity Framework (rather than a Table), make sure that the Key fields/properties are configured properly in the Model (EDMX). We recently experienced an anomaly where a Select All from a View-based Entity was not returning All the Entities we expected. There weren&#8217;t any [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=200&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When using a View as the basis for an Entity in the Entity Framework (rather than a Table), make sure that the Key fields/properties are configured properly in the Model (EDMX).  </p>
<p>We recently experienced an anomaly where a Select All from a View-based Entity was not returning All the Entities we expected.  There weren&#8217;t any filters, sorts, or joins, it was a straight select using Linq to Entities.<br />
Apparently, when we added the View to the Model, EF picked some columns (per its own magical algorithm) and made those the Key fields/Properties.  When it then loads the Entities from the recordset, any record with the same Key replaces an Entity that already has that Key.  So several of the records were, because of the EF generated Key, being replaced this way.<br />
We corrected the Key on the Entity (in both the Conceptual model and the Storage model), and the Select All returned all the right Entities, as expected.<br />
In our case, the View only returns 5 columns, so it was simple enough to make all the fields part of the Key.  For a larger query, if no compound key is apparent, I expect we would need to add a RowId to the View so that the EF can use that as a surrogate Key.  We do not actually use the View Key in the app (we only use the values in those rows to populate a list box that we then parse into several fields on selection), so we can use a surrogate Key without being concerned about the actual values that are actually being used.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=200&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/03/25/configure-the-key-when-using-views-as-the-basis-for-entities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>
	</item>
		<item>
		<title>Purpose and Principles of the Data Layer</title>
		<link>http://onemanwenttomow.wordpress.com/2010/03/17/purpose-and-principles-of-the-data-layer/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/03/17/purpose-and-principles-of-the-data-layer/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 17:52:40 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[Commentary]]></category>
		<category><![CDATA[DevArt dotConnect for Oracle]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Code Generation]]></category>
		<category><![CDATA[Data Layer]]></category>
		<category><![CDATA[DevArt dotConnect]]></category>
		<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/2010/03/17/purpose-and-principles-of-the-data-layer/</guid>
		<description><![CDATA[At its core, the Data Layer’s main purpose is: Data Layer’s Main Purpose: To abstract all interactions with the database so that business objects can be written to deal with business rules, not with database interaction. For example, when promoting a standard Deal, the business logic comprises: validate that the Deal is in a promotable [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=198&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At its core, the Data Layer’s main purpose is:   </p>
<table cellspacing="0" cellpadding="2" width="400" border="1">
<tbody>
<tr>
<td valign="top" width="400">
<p><b>Data Layer’s Main Purpose:</b> </p>
<p>To abstract all interactions with the database so that business objects can be written to deal with business rules, not with database interaction.</p>
</td>
</tr>
</tbody>
</table>
<p>For example, when promoting a standard Deal, the business logic comprises: </p>
<ol>
<li>validate that the Deal is in a promotable state</li>
<li>promote the Deal</li>
<li>generate the related Deal Transactions</li>
<li>generate the related Confirmation</li>
</ol>
<p>In addition to these items, there are interactions with the Deal Pricing, Deal Costing, Deal Transaction Pricing and a variety of other lookup tables. Records need to be saved, retrieved, updated and deleted to facilitate the persistence of the Deal’s new “Promoted” state. The Data Layer will encapsulate the code that interacts with the database, so the Deal Promoter class only needs to be concerned with the business rules of promoting a deal, and not with the mechanics of persisting those changes to the database. </p>
<h3>ORM Principles</h3>
<p>In order to effectively serve as an Object-Relational Mapping (ORM) tool, the Data Layer needs to implement the following principles. </p>
<h5>Principle 1: The Data Layer should generate the code necessary to deal with different tables and should provide a common API for working with the resulting data objects.</h5>
<p>A typical database interaction involves the following steps: </p>
<ol>
<li>Get the connection string</li>
<li>Open the connection</li>
<li>Create the command object</li>
<li>Execute the command</li>
<li>Close the connection</li>
</ol>
<p>The only thing that changes from table to table is the names of the table and its columns. All of the database code is identical. </p>
<h5>Principle 2: The Data Layer should be able to work with the entire Object Graph by saving and retrieving related objects as a set.</h5>
<p>Some objects are more complex than others, for example, a Deal has Pricing, Charges and Transactions that are an integral part of it. It also has Confirmations that are related to it. When saving a Deal, the pieces and parts of the Deal should get saved too. </p>
<h5>Principle 3: The Data Layer should handle failures within the context of a transaction and roll back the changes to a consistent, stable state.</h5>
<p>Sometimes, when saving a complex object, an error may occur in one of the pieces. In this case, the Data Layer should gracefully handle the error and leave the object and the database in a stable, consistent state. </p>
<h5>Principle 4: The Data Layer should intelligently map database tables to appropriate Business Objects. </h5>
<p>In several cases, a business object will represent a concept differently than the database might. For example, the database table EMPLOYEE contains all the records for the Employees, Managers and Direct Reports business classes. </p>
<h5>Principle 5: The Data Layer should handle concurrency properly.</h5>
<p>When objects are saved to the database, concurrency problems arise because the data being saved is about to overwrite data that has already changed since it was last retrieved. Concurrency resolutions include: Overwrite, Merge and Discard. The Data Layer needs to support these options and allow developers to choose which resolution to employ. </p>
<h3>Query Support</h3>
<h5>Principle 6: The Data Layer should support LINQ.</h5>
<p>In order to provide data sources for drop downs and grids the Data Layer needs to be able to support querying, including sorting, grouping and summarizing. There are three choices to do this: </p>
<p>1) Oracle native SQL queries </p>
<p>Implementing this technique often pushes Business and UI logic all the way back into the database. It makes ORM a challenge as the query objects are not like table-based as they are not updateable and do not usually have the necessary key fields. </p>
<p>2) Custom querying support in the Data Layer </p>
<p>Implementing this technique is complex, non-standard and may have performance issues. </p>
<p>3) LINQ (The .Net framework’s built in query language) </p>
<p>Implementing LINQ provides powerful, sophisticated, query capabilities. LINQ to Entities also raises performance by taking advantage of the Entity Framework’s knowledge of the database objects. </p>
<h5>Principle 7: The Data Layer should support asynchronous communication.</h5>
<p>One of the worst aspects of application performance is the perceived lag while waiting for data to be retrieved from a database, transferred over the network and rendered in the UI. Asynchronous communication is the recommended way to prevent this lag by allowing the UI to be responsive while the data is retrieved, transferred, and even rendered, asynchronously. In Silverlight, all network communication is asynchronous, so the Data Layer must support asynchronous communication. </p>
<h3>Oracle Support</h3>
<h5>Principle 8: The Data Layer should support Oracle specific features, such as Sequences, Packages and Oracle Data Types.</h5>
<p>Most Oracle tables have a key field that is a numeric tied to a Sequence value. Much of the legacy code is embedded in the Database in Oracle Packages. There are also some Oracle specific Data Types (particularly LOB’s) that need to be translated to/from their .Net equivalents. The Data Layer needs to handle all three of these situations properly. </p>
<h3>Trouble Shooting Support</h3>
<h5>Principle 9: The Data Layer should support granular logging for debugging and troubleshooting.</h5>
<p>When debugging and troubleshooting, a detailed log of what is happening can be a very useful tool. Especially in asynchronous or Inversion of Control situations where the code cannot be easily stepped through, a log is critical to the discovery and elimination of bugs. </p>
<h3>Performance Enhancement</h3>
<h5>Principle 10: The Data Layer should support server-side and client-side caching to improve performance.</h5>
<p>Data Caching on the Server-side allows redundant calls for data from different clients to be served in a single database request. Data Caching on the Client-side allows redundant calls for data on the client to be served on the client without any network traffic at all. </p>
<h5>Principle 11: The Data Layer should support validation at the client and at the server to improve performance.</h5>
<p>Eliminating round trips by providing client-side validation will improve performance. Providing server-side validation will ensure data integrity at the server.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/198/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/198/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/198/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=198&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/03/17/purpose-and-principles-of-the-data-layer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>
	</item>
		<item>
		<title>IdeaBlade DevForce – Model Setup Walk-through – Step 2:  The DevForce Projects</title>
		<link>http://onemanwenttomow.wordpress.com/2010/03/04/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-2-the-devforce-projects/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/03/04/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-2-the-devforce-projects/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 21:59:08 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[Silverlight Development]]></category>
		<category><![CDATA[DevArt]]></category>
		<category><![CDATA[DevArt dotConnect for Oracle]]></category>
		<category><![CDATA[DevArt Entity Developer]]></category>
		<category><![CDATA[DevForce]]></category>
		<category><![CDATA[dotConnect]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Entity Framework Model]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Silverlight Web Service]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/?p=176</guid>
		<description><![CDATA[Our Problem: We need to create an Enterprise application that is web-based, has an Excel-ish interface and pulls data from an Oracle database. Technologies Chosen*: Silverlight for the UI Prism 2 for the modular framework Unity for DI IdeaBlade DevForce for the Business Object Layer and Async functionality MS Entity Framework for the ORM DevArt [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=176&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><H3>Our Problem:</H3><br />
We need to create an Enterprise application that is web-based, has an Excel-ish interface and pulls data from an Oracle database.</p>
<p>
<H3>Technologies Chosen*:</H3></p>
<ul>
<li>Silverlight for the UI</li>
<li>Prism 2 for the modular framework</li>
<li>Unity for DI</li>
<li>IdeaBlade DevForce for the Business Object Layer and Async functionality</li>
<li>MS Entity Framework for the ORM</li>
<li>DevArt dotConnect for Oracle (EF Drivers)</li>
<li>Oracle 11 Database</li>
</ul>
<p>* See <a href="http://onemanwenttomow.wordpress.com/2010/02/25/ideablade-devforce-model-setup-walk-through-background/">here</a> for our reasoning.<br />
<H3>Prerequisites:</H3></p>
<ol>
<li>Complete the procedures documented in <a href="http://onemanwenttomow.wordpress.com/2010/03/04/ideablade-devforce-%E2%80%93-model-setup-walk-through-%E2%80%93-step-1-the-entity-framework-project/">Step 1</a></li>
<li>Install IdeaBlade&#8217;s <a href="http://www.ideablade.com/DevForceSilverlight/DevForceSilverlight_overview.aspx">DevForce for Silverlight</a> tool.</li>
<li>Install the <a href="http://silverlight.net/getstarted/">Silverlight</a> development environment.  This comprises:
<ol style="list-style-type:lower-alpha;">
<li>The Silverlight 3 <a href="http://go.microsoft.com/fwlink/?linkid=150228">Developer Runtime</a></li>
<li>The Silverlight 3 <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9442b0f2-7465-417a-88f3-5e7b5409e9dd&amp;displaylang=en">Tools for VS 2008</a></li>
<li>The Silverlight 3 <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1ea49236-0de7-41b1-81c8-a126ff39975b&amp;displaylang=en">SDK</a></li>
</ol>
</li>
</ol>
<p />
<H3>Creating the DevForce model projects:</H3><br />
There will be two DevForce model projects, one will be a C# library project that runs on the server, the other will be a Silverlight library that runs in the Silverlight client.  The DevForce framework takes care of wiring these two together with a couple of WCF services that are hosted in the Web application that hosts the DevForce components and the Silverlight app.</p>
<p>To create the projects:</p>
<ol>
<li>Open the Entity Framework model solution created in Step 1 of this walkthrough.</li>
<p />
<li>Select Tools | DevForce Object Mapper</li>
<p />
<li>DevForce naturally works with EDMX files (Model | Add Entity Model), but we have an EDML file from the devArt Entity Developer, so we have to use File | Open to get to it.
<p />
Select <b>File | Open</b>, change the Files of type to All Files.  Select the <code>Model_Widget.edml</code> file and click Open.<br />
At this point, DevForce has opened the EF model.  Now, we have to tell it how we want the projects to be configured.</li>
<p />
<li>First, click the New Project button for the Domain Model project.<br />
The Project Name needs to follow our assembly naming convention, so for this walkthrough, I am using <code>Acme.BirdTrap.Model.Widget</code> (with no suffix).<br />
I will leave the Project Type and Location at their defaults.
</li>
<p />
<li>Second, click the New Project button for the Silverlight project.<br />
The Project Name needs to follow our assembly naming convention, so for this walkthrough, I am using <code>Acme.BirdTrap.Model.WidgetSL</code> (with the SL = Silverlight suffix).<br />
I will leave the Project Type and Location at their defaults.
</li>
<p />
<li>Back on the new model tab:
<ol style="list-style-type:lower-alpha;">
<li>Set the Namespace to:  <code>Acme.BirdTrap.Model.Widget</code></li>
<li>Set the EntityManager name to something more model specific, we use a standard of <i>Module</i>EntityManager as the application may need to work with multiple modules&#8217; EntityManagers at the same time.<br />
I have selected to name the Entity Manager: <code>WidgetEntityManager</code>.
</li>
</ol>
<p />
<a href="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-1-18-40-pm.png"><img src="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-1-18-40-pm.png?w=300&#038;h=247" alt="New Devforce Project Settings" title="New Devforce Project Settings" width="300" height="247" class="alignnone size-medium wp-image-182" /></a></p>
<p>[Note: See Ward Bell's essay on the topic of <a href="http://www.ideablade.com/WardsCorner/LargeEFModels.pdf">Large Models</a> for more about splitting your model and using multiple Entity Managers.]
</li>
<p />
<li>Select the Model_WidgetEF.edml branch of the Model tree on the left.  You will see the settings available for this EF Model.
<ol style="list-style-type:lower-alpha;">
<li>Change the DataSourceKeyName to something more model specific, we use a standard of <i>Module</i>DataSource as each module/model needs a different DataSource definition.<br />
I have selected to name the Data Source Key: <code>WidgetDataSource</code></li>
<li>This is also the place where you inject your own base Entity class implementations into the DevForce model.  At the very least, you should create a <code>BaseEntity</code> class where you can put common Entity functionality.  Click the Injected Base Types button and add <code>Acme.BirdTrap.Utility.Persistence.BaseEntity</code> to the list, setting it as the default. (In a future posting, I will be examining the Injected Base Types in greater depth.)</li>
<li>The name pluralizer is a great feature of DevForce but it is completely irrelevant to us as devArt&#8217;s Entity Developer tool has taken care of pluralization for us.</li>
</ol>
<p />
<li>Click the Save button on the toolbar.  DevForce will now create and initialize the two projects we have defined.  When it has finished, close the DevForce Object Mapper.</li>
<p />
<li>Next, we need to create the BaseEntity class we added to the Injected Base Types earlier.
<ol style="list-style-type:lower-alpha;">
<li>In the new C# project, <code>Acme.birdTrap.Model.Widget</code>, add a new class named <code>Acme.BirdTrap.Utility.Persistence.BaseEntity</code> that inherits from <code>IdeaBlade.EntityModel.Entity</code><br />
<pre class="brush: csharp;">using IdeaBlade.EntityModel;

namespace Acme.BirdTrap.Utility.Persistence
{
    public class BaseEntity : Entity
    {   
    }
}</pre></li>
<li>In the new Silverlight project, <code>Acme.birdTrap.Model.WidgetSL</code>, add an Existing Item, then navigate to the BaseEntity class you just created in the C# project, drop down the Add button and choose Add as Link.</li>
</ol>
</li>
<p />
<li>I bet you wish we were done at this point.  We are not.  DevForce made some assumptions in generating the projects that we need to fix.
<p>First, and really only a cosmetic issue, DevForce created a Solution Folder for the DomainModel.  You can choose to keep this or not.  This whole solution is for my DomainModel, so I do not need this new folder.  If I incorporate the Model projects into a larger Module level Solution, then I will use a Solution Folder for the Model projects in that solution, but I do not need one here.  To remove the folder, I drag the two new projects up out of the folder into the Solution level and then Remove the folder.</li>
<p />
<li>Second, and by far more serious, DevForce pulled in a bunch of referenced components, some of theirs, some of the .Net Framework&#8217;s and some from the Silverlight SDK.<br />
There are three places where referenced assemblies can safely live:</p>
<ol style="list-style-type:lower-roman;">
<li><code>\WINDOWS\Microsoft.NET\Framework\**.*</code></li>
<li><code>\Program Files\Reference Assemblies\**.*</code></li>
<li>Your solution&#8217;s <code>dependencies\**.*</code></li>
</ol>
<p />
<ol style="list-style-type:lower-alpha;">
<li>Examining the C# project (<code>Acme.BirdTrap.Model.Widget</code>), we find the IdeaBlade assemblies are referenced from <code>Program Files</code>.  We can change that by: first, removing the <code>Ideablade.Core</code>, <code>Ideablade.EntityModel</code>, <code>Ideablade.Validation</code>,assemblies; then adding them back from the <code>dependencies\IdeaBlade DevForce\</code> folder.</li>
<li>Examining the Silverlight project (<code>Acme.BirdTrap.Model.WidgetSL</code>), we find the IdeaBlade Silverlight assemblies are referenced wrong, which can be corrected as above, only adding back from the <code>dependencies\IdeaBlade DevForce\SilverlightAssemblies</code> folder this time.<br />
However, we also find that the <code>System.ComponentModel.DataAnnotations</code> assembly is being pulled from <code>\Program Files\Microsoft SDKs\</code> folder.  Remove it and add it back from <code>dependencies\Silverlight\Libraries\Client\</code>.</li>
</ol>
</li>
<p />
<li>That&#8217;s it, right?  We&#8217;ve created the files and all is well.  If you try to Build your solution right now, you will get errors originating from the EF project.  But it was fine before we started, and we didn&#8217;t change it &#8212; or did we?<br />
In fact, we did.  When you point the DevForce Object Mapper at the EF project&#8217;s EDML file, DevForce adds a bunch of attributes to some of the elements in that file.  In doing so, the DevArt Entity Developer notices the EDML has changed and wipes the generated *.designer.cs file.  To restore this, you need to re-open the EDML file and regenerate the generated code.  But here&#8217;s the rub, if you open the EDML file from within Visual Studio, the devArt Entity Developer will only regenerate the code if you make changes to the model.  But we don&#8217;t want to make changes to the model.<br />
Instead, open the EDML file from Windows Explorer.  This will open the Entity Developer and reveal a Generate Code button on the toolbar:<br />
<a href="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-4-07-12-pm2.png"><img src="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-4-07-12-pm2.png?w=300&#038;h=50" alt="Generate Code button" title="Generate Code button" width="300" height="50" class="alignnone size-medium wp-image-188" /></a><br />
Clicking this button, will regenerate the missing generated code without requiring a model change.  You can then exit the Entity Developer.</li>
<li><b><font color="Blue">DONE.</font></b></li>
</ol>
<p><H3>Conclusion</H3><br />
In this part of the walk through, we have created the pair of DevForce C# and Silverlight projects that contain our Domain Model.<br />
The solution successfully Builds and the EF unit test we created in Step 1 still passes.  Now we need to create a pair of Unit Test projects to ensure that the DevForce framework is configured properly and can successfully CRUD the database through the EF layer.  But that will have to wait until the next part of the walk through.</p>
<p>Until then: I&#8217;m off to take the dog for a walk! Woof!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=176&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/03/04/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-2-the-devforce-projects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-1-18-40-pm.png?w=300" medium="image">
			<media:title type="html">New Devforce Project Settings</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2010/03/3-4-2010-4-07-12-pm2.png?w=300" medium="image">
			<media:title type="html">Generate Code button</media:title>
		</media:content>
	</item>
		<item>
		<title>IdeaBlade DevForce – Model Setup Walk-through – Step 1:  The Entity Framework Project</title>
		<link>http://onemanwenttomow.wordpress.com/2010/03/02/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-1-the-entity-framework-project/</link>
		<comments>http://onemanwenttomow.wordpress.com/2010/03/02/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-1-the-entity-framework-project/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 14:38:37 +0000</pubDate>
		<dc:creator>Simon Kingaby</dc:creator>
				<category><![CDATA[DevArt dotConnect for Oracle]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[DevArt Entity Developer]]></category>
		<category><![CDATA[Entity Framework Model]]></category>
		<category><![CDATA[IdeaBlade DevForce]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Silverlight Development]]></category>

		<guid isPermaLink="false">http://onemanwenttomow.wordpress.com/?p=130</guid>
		<description><![CDATA[Our Problem: We need to create an Enterprise application that is web-based, has an Excel-ish interface and pulls data from an Oracle database. Technologies Chosen*: Silverlight for the UI Prism 2 for the modular framework Unity for DI IdeaBlade DevForce for the Business Object Layer and Async functionality MS Entity Framework for the ORM DevArt [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=130&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><H3>Our Problem:</H3><br />
We need to create an Enterprise application that is web-based, has an Excel-ish interface and pulls data from an Oracle database.</p>
<p>
<H3>Technologies Chosen*:</H3></p>
<ul>
<li>Silverlight for the UI</li>
<li>Prism 2 for the modular framework</li>
<li>Unity for DI</li>
<li>IdeaBlade DevForce for the Business Object Layer and Async functionality</li>
<li>MS Entity Framework for the ORM</li>
<li>DevArt dotConnect for Oracle (EF Drivers)</li>
<li>Oracle 11 Database</li>
</ul>
<p>* See <a href="http://onemanwenttomow.wordpress.com/2010/02/25/ideablade-devforce-model-setup-walk-through-background/">here</a> for our reasoning.<br />
<H3>Prerequisites:</H3><br />
Install the <a href="http://www.devart.com/dotconnect/oracle/">DevArt dotConnect for Oracle</a> drivers.  (This includes the DevArt Entity Developer tool).</p>
<p>
<H3>Database Structure:</H3><br />
For this walkthrough, I have created the following table:<br />
<pre class="brush: sql;">CREATE TABLE SAMPLE_WIDGET 
(
    SAMPLE_WIDGET_ID int,
    DESCRIPTION varchar(100),
    CONSTRAINT SAMPLE_WIDGET_PK 
    PRIMARY KEY (SAMPLE_WIDGET_ID)
);
/
CREATE SEQUENCE SAMPLE_WIDGET_ID_SEQ;
/
CREATE TRIGGER SAMPLE_WIDGET_GETSEQ 
BEFORE INSERT
ON SAMPLE_WIDGET
FOR EACH ROW WHEN (NEW.SAMPLE_WIDGET_ID IS NULL)
BEGIN
    SELECT SAMPLE_WIDGET_ID_SEQ.nextval INTO :NEW.SAMPLE_WIDGET_ID FROM dual;
END;
/
INSERT INTO SAMPLE_WIDGET (DESCRIPTION) VALUES ('Widget 1');
INSERT INTO SAMPLE_WIDGET (DESCRIPTION) VALUES ('Widget 2');
INSERT INTO SAMPLE_WIDGET (DESCRIPTION) VALUES ('Widget 3');
INSERT INTO SAMPLE_WIDGET (DESCRIPTION) VALUES ('Widget 4');
COMMIT;
/</pre><br />
<H3>Creating the EF Project</H3></p>
<ol>
<li>In Visual Studio 2008, select File | New Project | C# Class Library.
<p><table border="1">
<tr>
<td style="padding:10px;">
<b>Naming the Project</b><br />
There will be 3 model projects:</p>
<ul>
<li>The EF project</li>
<li>The server-side DevForce project</li>
<li>The client-side (Silverlight) DevForce project</li>
</ul>
<p>We have opted to follow a <i>[Company].[Application].[Component].[Module][Suffix]</i> project naming convention.<br />
For example:  <code>Acme.BirdTrap.Model.WidgetSL</code> would denote a Silverlight Model project for the Widget module of the BirdTrap application at Acme company.</td>
</tr>
</table>
<p>For this walkthrough, I will name the EF project:  </p>
<p style="padding-left:20px;"><code>Acme.BirdTrap.Model.WidgetEF.csproj</code></p>
<p>And, I will name the Model solution:  </p>
<p style="padding-left:20px;"><code>Acme.BirdTrap.Model.sln</code></p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-3-46-51-pm1.png"><img src="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-3-46-51-pm1.png?w=300&#038;h=218" alt="Project Creation Dialog" title="Project Creation Dialog" width="300" height="218" class="alignnone size-medium wp-image-149" /></a>
</li>
<p />
<li>Delete the <code>Class1.cs</code></li>
<p />
<li>Add the references so we can use Oracle and the EF.
<p><table border="1">
<tr>
<td style="padding:10px;">But, wait. Before we add the references, we need to decide where the referenced items will live.  Every solution <i>should</i> carry with it <b>all</b> the components (DLL&#8217;s) that are not part of the official Microsoft environment and that are needed to build it.  These should be checked in to SCM with that solution. If not, then developers will be pointing projects to their Program Files directory and/or other random places when they add references to projects.<br />
To address this problem, we create two solution level folders, one for dependencies and one for installations.  </p>
<p><a href="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-4-09-05-pm3.png"><img src="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-4-09-05-pm3.png?w=300&#038;h=114" alt="Project Folders" title="Project Folders" width="300" height="114" class="alignnone size-medium wp-image-148" /></a></p>
<dl>
<dt>The <b><code>installation</code></b> folder.</dt>
<dd>Contains the Full Install package for each of the Third Party tools we use.  These are checked in and promoted along with the code.  This ensures that everyone is building with the same set of tools.  If someone updates their PC and our solution to use a new version of a tool, the promoted code will be accompanied by a new Install package so all developers can update the version of the tool their using before trying to compile the updated code.</dd>
<dt>The <b><code>dependencies</code></b> folder.</dt>
<dd>Contains all the DLL files that are referenced by the projects in the Solution, except the ones that are part of the Microsoft .Net Framework.  In so far as technologies like Silverlight are installed to the GAC as extensions to the .Net Framework, those DLL&#8217;s are referenced from the GAC and are not copied to the dependencies folder.  All other referenced DLL&#8217;s ARE copied to dependencies though.  This includes the Silverlight Toolkit files, the IdeaBlade files, DevArt files, etc.</dd>
</dl>
<p />
So, before we can create the references in our WidgetEF project, we need to create our installations and dependencies folders and copy the DLL files from the installed locations in Program files to the appropriate locations in the dependencies folders.</td>
</tr>
</table>
<p>Now the files are in the right place, we can add the references to the WidgetEF project.</p>
<ol style="list-style-type:lower-alpha;">
<li>From the Add Reference dialog, on the .NET tab, select the System.Data.Entity 3.5 and  System.Runtime.Serialization 3.0 components.</li>
<li>On the Browse tab, navigate to the dependencies\DevArt dotConnect folder, select the DevArt.Data.Oracle.Entity.dll.</li>
</ol>
</li>
<p />
<li>Create the Entity Model.  In the WidgetEF project, select to Add a New Item.  Select the Data category, and choose the DevArt Entity Model item.  When naming the model file, we have been naming them Model_EF.<br />
For this walkthrough, I will name the model file:  <code>Model_WidgetEF.edml</code>.<br />
At this point, DevArt&#8217;s Entity Developer will open.  </p>
<ol style="list-style-type:lower-alpha;">
<li>Select the Project |Properties menu item.  Select the Model tab.</li>
<li>Change the EntityContainerName to <code>Entities</code>.  The one that the tool provides is based on the model file name, which is not useful to us within the application.  Naming ALL of your model Containers as Entities means that all of your modules can use <code><i>Namespace</i>.Entities.<i>ObjectClass</i></code> to access the object classes.</li>
<li>Change the  Namespace to the correct one.  Again, the default is based on the model file name, so it will never be correct.  I used: <code>Acme.BirdTrap.Model.WidgetEF</code>.</li>
<li>Check the &#8220;View Generation&#8221; checkbox.</li>
<li>Use the Database Explorer pane to connect to your database.</li>
<li>Drag the SAMPLE_WIDGET table over to the Model pane.</li>
<li>When we created the SAMPLE_WIDGET table, we used a SEQUENCE and a TRIGGER to auto-increment the primary key Id field.  This makes our table behave the same way as an Identity column in SQL Server, which EF knows how to deal with.  We need to tell our model, that the SampleWidgetId field is an autonumber field.  DevArt has made this easy.<br />
In the Project Explorer, there are two main branches.<br />
The top branch (Acme.BirdTrap.Model.WidgetEF), is the Conceptual (or Object) model.<br />
The lower branch (Acme.BirdTrap.Model.WidgetEF<b>.Store</b>) is the Storage (or Database) model.<br />
(The Mapping model is not represented in this tree because it is handled in the Mapping editor for each Class/Property in the Conceptual model.)</p>
<ol style="list-style-type:lower-roman;">
<li>Open up the lower branch (the .Store branch).</li>
<li>Expand the Tables/Views branch.</li>
<li>Expand the SAMPLE_WIDGET table branch.</li>
<li>Select the SAMPLE_WIDGET_ID column.</li>
<li>Now, in the Properties pane, you will see the properties of the SAMPLE_WIDGET_ID column.</li>
<li>Select the Store Generated Pattern property and change the value to Identity.</li>
</ol>
</li>
<p />
<li>Save the Model.</li>
<li>Close the Entity Developer.</li>
</ol>
<p />
<li>Back in VS, expand the file tree below the new .edml file so you see the following files:
<dl>
<dt><code>Model_WidgetEF.edml</code></dt>
<dd>The XML definition of the model itself.  This corresponds to the .edmx file created by the MS Entity Designer.  You will usually edit this file using the DevArt Entity Developer tool, but you will occasionally need to edit the XML directly in a text editor.  There is plenty of technical <a href="http://msdn.microsoft.com/en-us/library/bb399604.aspx">documentation</a> on MSDN about this file, but none of it is particularly instructive.</dd>
<dt><code>Model_WidgetEF.cs</code></dt>
<dd>A one-time generated file with a Partial declaration of the Entities class for you change as needed.  (We change it in one of the steps below.)</dd>
<dt><code>Model_WidgetEF.Designer.cs</code></dt>
<dd>The generated code for your entities.  Do not change this file.  Period.</dd>
<dt><code>Model_WidgetEF.edml.view</code></dt>
<dd>The diagram layout, written in XML.  This file is only relevant to the Entity Developer tool.(And I love that DevArt put this in a separate file instead of tacking it on the bottom of the EDMX file like MS did.)</dd>
<dt><code>Model_WidgetEF.edps</dt>
<p></code>
<dd>This XML file defines the tool settings, output path and connection string used by the Entity Developer and the code generator.  You will not need to change this file until you need to build against a different database.  These changes will be explained further in a later posting on building and deploying the model solution.</dd>
<dt><code>Model_WidgetEF.PregeneratedViews.cs</code></dt>
<dd>The pregenerated views used by the Entity Framework.  If these views are pregenerated, they can be compiled into the assembly and they will not need to be generated dynamically at application startup.  In my projects, this seems to have saved us anywhere from 1-10 seconds off the total spin up time.</dd>
</dl>
</li>
<p />
<li>In order to fix <a href="http://www.DevArt.com/forums/viewtopic.php?t=16014&amp;start=0&amp;postdays=0&amp;postorder=asc&amp;highlight=oncontextcreated">the ORA-01790 weirdness</a>, open the Model_WidgetEF.cs file and add this snippet:<br />
<pre class="brush: csharp;">partial void OnContextCreated()
{
	DevArt.Data.Oracle.Entity.OracleEntityProviderServices.TypedNulls = true;
}</pre></li>
<li>Last, but not least, in order to deploy this project to run against a different database, we will need to be able to regenerate the PregeneratedViews without running the UI tool.  I.e. Regenerate from the command line.  The easiest way to do that will be using a <a href="http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx">T4 template</a>.<br />
There is a good <a href="http://blogs.msdn.com/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx">article here</a> about using a T4 template to create the views for a MS EDMX model.  I started by using their <a href="http://blogs.msdn.com/adonet/attachment/8626631.ashx">CSharp.Views.tt</a> file.</p>
<p>The change necessary to make this work for our DevArt EDML model is:<br />
<pre class="brush: csharp;">string edmxFileName = Path.GetFileNameWithoutExtension(this.Host.TemplateFile).ToLowerInvariant().Replace(&quot;.views&quot;, &quot;&quot;) + &quot;.edmx&quot;;</pre></p>
<p><i>Should be:</i></p>
<p><pre class="brush: csharp;">string edmxFileName = Path.GetFileNameWithoutExtension(this.Host.TemplateFile).ToLowerInvariant().Replace(&quot;.pregeneratedviews&quot;, &quot;&quot;) + &quot;.edml&quot;;
</pre></li>
<li>A weird thing happened when I added the .tt file to my project.  Even though I clicked cancel, it still ran the .tt template anyway, and it created a Model_WidgetEF.PregeneratedViews1.cs file that I don&#8217;t want.  To fix this, and get the .tt nested properly under the .edml file, we need to manipulate the .csproj file by hand.  Close the project in VS.  Open the .csproj file in the text editor of your choice.  Locate this code:
<p><pre class="brush: xml;">&lt;Compile Include=&quot;Model_WidgetEF.PregeneratedViews.cs&quot;&gt;
  &lt;DependentUpon&gt;Model_WidgetEF.edml&lt;/DependentUpon&gt;
&lt;/Compile&gt;
&lt;Compile Include=&quot;Model_WidgetEF.PregeneratedViews1.cs&quot;&gt;
  &lt;AutoGen&gt;True&lt;/AutoGen&gt;
  &lt;DesignTime&gt;True&lt;/DesignTime&gt;
  &lt;DependentUpon&gt;Model_WidgetEF.PregeneratedViews.tt&lt;/DependentUpon&gt;
&lt;/Compile&gt;</pre></p>
<p>Move the contents of the second  tag into the first and remove the second, so the code looks like this:</p>
<p><pre class="brush: xml;">&lt;Compile Include=&quot;Model_WidgetEF.PregeneratedViews.cs&quot;&gt;
  &lt;DependentUpon&gt;Model_WidgetEF.edml&lt;/DependentUpon&gt;
  &lt;AutoGen&gt;True&lt;/AutoGen&gt;
  &lt;DesignTime&gt;True&lt;/DesignTime&gt;
&lt;/Compile&gt;</pre></p>
<p>Now find this code:</p>
<p><pre class="brush: xml;">&lt;None Include=&quot;Model_WidgetEF.PregeneratedViews.tt&quot;&gt;
  &lt;Generator&gt;TextTemplatingFileGenerator&lt;/Generator&gt;
  &lt;LastGenOutput&gt;Model_WidgetEF.PregeneratedViews1.cs&lt;/LastGenOutput&gt;
&lt;/None&gt;</pre></p>
<p>Remove the 1 from the PregeneratedViews1.cs file name and add a  element, so the code looks like this:</p>
<p><pre class="brush: xml;">&lt;None Include=&quot;Model_WidgetEF.PregeneratedViews.tt&quot;&gt;
  &lt;Generator&gt;TextTemplatingFileGenerator&lt;/Generator&gt;
  &lt;LastGenOutput&gt;Model_WidgetEF.PregeneratedViews.cs&lt;/LastGenOutput&gt;
  &lt;DependentUpon&gt;Model_WidgetEF.edml&lt;/DependentUpon&gt;
&lt;/None&gt;</pre></p>
<p>Note: The T4 engine and the Entity Developer tool will each take ownership of the .PregeneratedViews.cs file.  So depending which tool ran last, the views may be nested under the .edml file, or under the .tt file.</li>
<p />
<li><b><font color="blue">DONE.</font></b>  The EF model project is complete.  Before going any further, let&#8217;s set up a simple unit test to make sure we have connectivity and can read data.</li>
<p><H3>Creating the EF Unit Test Project</H3></p>
<li>Add a new Test Project to the solution.  We name each test project with the same name as the assembly it tests, suffixed with .Test, so in this case, it is: Acme.BirdTrap.Model.WidgetEF.Test.</li>
<li>Add references to:<br />
* The model project: Acme.BirdTrap.Model.WidgetEF<br />
* System.Data<br />
* System.Data.Entity<br />
(You do not need to add Linq or Xml or any DevArt components.)
</li>
<li>Copy or link the app.config from the Model EF project to the Test project.</li>
<li>Create a test class that performs the basic CRUD operations:
<p><pre class="brush: csharp;">using System;
using System.Data;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Acme.BirdTrap.Model.WidgetEF.Test
{
    /// &lt;summary&gt;
    /// Summary description for UnitTest1
    /// &lt;/summary&gt;
    [TestClass]
    public class ModelWidgetEfTest
    {

        private readonly string _testWidget = &quot;UT&quot; + DateTime.Now;

        [TestMethod]
        public void LoadWidgetsTest()
        {
            //instantiate the model
            var entities = new Entities();

            //get the widgets
            var widgets = from item 
                          in entities.SampleWidgets 
                          select item;
            
            //make sure we got some widgets
            Assert.IsNotNull(widgets, &quot;LoadWidgetsTest: returned Null&quot;);
            Assert.IsTrue(widgets.Count() &gt; 0, &quot;LoadWidgetsTest:  Returned no widgets.&quot;);
        }

        [TestMethod]
        public void CreateAWidgetTest()
        {
            //instantiate the model
            var entities = new Entities();

            //create a sample widget
            var widget = new SampleWidget { Description = _testWidget };
            //cache the id of the new widget
            var id = widget.SampleWidgetId;
            
            //add the widget to the Entities collection
            entities.AddToSampleWidgets(widget);  
            
            //save the new widget
            var result = entities.SaveChanges();

            Assert.IsTrue(result &gt; 0, &quot;CreateAWidgetTest: Save new widget failed.&quot;);
            Assert.AreNotEqual(0, widget.SampleWidgetId, &quot;CreateAWidgetTest: Saved Id is still zero.&quot;);
            Assert.AreNotEqual(id, widget.SampleWidgetId, &quot;CreateAWidgetTest: Save Id did not get updated by the trigger.&quot;);
        }

        [TestMethod]
        public void EditAWidgetTest()
        {
            //instantiate the model
            var entities = new Entities();
            
            //get the sample widget
            var widget = (from item
                          in entities.SampleWidgets
                          where item.Description == _testWidget
                          select item).First();
            
            //make sure we got the widget
            Assert.IsNotNull(widget, &quot;EditAWidgetTest: returned Null&quot;);
            
            //change the widget
            widget.Description = &quot;Changed Widget&quot;;

            //save the changed widget
            var result = entities.SaveChanges();

            Assert.IsTrue(result &gt; 0, &quot;EditAWidgetTest: Save changed widget failed.&quot;);
            Assert.AreEqual(&quot;Changed Widget&quot;, widget.Description, &quot;EditAWidgetTest: Saved description changed unexpectedly&quot;);
        }

        [TestMethod]
        public void DeleteAWidgetTest()
        {
            //instantiate the model
            var entities = new Entities();

            //get the sample widget
            var widget = (from item
                          in entities.SampleWidgets
                          where item.Description == &quot;Changed Widget&quot;
                          select item).First();

            //make sure we got the widget
            Assert.IsNotNull(widget, &quot;DeleteAWidgetTest: returned Null&quot;);

            //delete the widget
            entities.DeleteObject(widget);

            //save the deletion, so the widget record is removed
            var result = entities.SaveChanges();

            Assert.IsTrue(result &gt; 0, &quot;DeleteAWidgetTest: Save deleted widget failed.&quot;);
            Assert.AreEqual(EntityState.Detached, widget.EntityState, &quot;widget was not detached when it was saved&quot;);
        }

        [TestMethod]
        public void TryToLoadTheDeletedWidgetTest()
        {
            //instantiate the model
            var entities = new Entities();

            var widgets = from item
                          in entities.SampleWidgets
                          where item.Description == &quot;Changed Widget&quot;
                          select item;

            Assert.IsTrue(widgets.Count() == 0, &quot;TryToLoadTheDeletedWidgetTest:  Returned a widget when it shouldn't.&quot;);
        }
    }
}</pre></li>
<li>Create an OrderedTest class that runs the CRUD operations in the right order:  Load, Create, Edit, Delete, then TryToLoadAfterDelete.</li>
<li>To run the OrderedTest, open the Test View pane (menu Test | Windows | Test View).  Select the Ordered Test and run it.  It should be green lights all the way.
</li>
</ol>
<p><H3>Conclusion</H3></p>
<p>In this part of the walk through, we have created the Entity Framework model project for an Oracle database using the DevArt dotConnect drivers and its accompanying Entity Developer tool.</p>
<p>In the next part of the walk through, we will set up the IdeaBlade DevForce models that sit on top of the EF model.</p>
<p>Until then: Get outside and enjoy the sunshine.  Which is to say, &#8220;Take the dog for a walk!&#8221;  Woof!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/onemanwenttomow.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/onemanwenttomow.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/onemanwenttomow.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=onemanwenttomow.wordpress.com&amp;blog=2410747&amp;post=130&amp;subd=onemanwenttomow&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://onemanwenttomow.wordpress.com/2010/03/02/ideablade-devforce-%e2%80%93-model-setup-walk-through-%e2%80%93-step-1-the-entity-framework-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8b80d5c91abc8655d297ae0eb0e866a3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">skingaby</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-3-46-51-pm1.png?w=300" medium="image">
			<media:title type="html">Project Creation Dialog</media:title>
		</media:content>

		<media:content url="http://onemanwenttomow.files.wordpress.com/2010/03/3-1-2010-4-09-05-pm3.png?w=300" medium="image">
			<media:title type="html">Project Folders</media:title>
		</media:content>
	</item>
	</channel>
</rss>
