<?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/"
	>

<channel>
	<title>Jason Rowe</title>
	<atom:link href="http://jasonrowe.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasonrowe.com</link>
	<description>digging into the details</description>
	<lastBuildDate>Tue, 09 Feb 2010 05:26:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>System.Reactive IScheduler Hello World</title>
		<link>http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/</link>
		<comments>http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 23:16:14 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=987</guid>
		<description><![CDATA[I&#8217;ve been following the Reactive Extensions work on blogs, podcasts and forums. It sounds and looks amazing. The icing on the cake is Bart De Smet is going to be involved and it uses the new Parallel framework (TPL).
Photo of cake icing to make some odd point.

After watching this great video Controlling concurrency in Rx [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been following the <a href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx">Reactive Extensions</a> work on <a href="http://blogs.msdn.com/rxteam/default.aspx">blogs</a>, <a href="http://www.hanselminutes.com/default.aspx?showID=216">podcasts</a> and <a href="http://social.msdn.microsoft.com/Forums/en-US/rx/threads">forums</a>. It sounds and looks amazing. The icing on the cake is <a href="http://community.bartdesmet.net/blogs/bart/archive/2010/01/10/2010-a-personal-change-putting-my-head-in-the-cloud.aspx">Bart De Smet</a> is going to be involved and it uses the new <a href="http://msdn.microsoft.com/en-us/concurrency/default.aspx">Parallel framework (TPL)</a>.</p>
<p>Photo of cake icing to make some odd point.<br />
<img src="http://jasonrowe.com/wp-content/uploads/2010/02/cake_icing.jpg" alt="" title="cake_icing" width="300" height="200" class="alignnone size-full wp-image-1003" /></p>
<p>After watching this great video <a href="http://blogs.msdn.com/rxteam/archive/2009/12/18/controlling-concurrency-in-rx.aspx">Controlling concurrency in Rx</a> on the RX team blog. I was inspired to start trying out the scheduler. Below are my basic code snippets that would be the equivalent of a hello world.</p>
<p>The first code snippet below uses the &#8220;Now&#8221; and &#8220;Later&#8221; schedulers that are provided. They follow this pattern respectively. <code>Schedule(Action); Schedule(Action, TimeSpan);</code>.</p>
<pre class="brush: c#; ">

 static void Main(string[] args)
        {
            var timespan = new TimeSpan(0, 0, 5);

            using (Scheduler.Later.Schedule(DoSomeActionLater, timespan))
            {
                using (Scheduler.Now.Schedule(DoSomeAction))
                {
                    Console.WriteLine(&quot;type q to quit&quot;);

                    while (Console.ReadLine() != &quot;q&quot;)
                    {
                        Thread.Sleep(1000);
                        Console.WriteLine(&quot;...&quot;);
                    }

                }
            }
        }

        public static void DoSomeActionLater()
        {
            Console.WriteLine(&quot;Later&quot;);
        }

        public static void DoSomeAction()
        {
            Console.WriteLine(&quot;Now&quot;);
        }
</pre>
<p>This will give you some output similar to this.<br />
<a href="http://jasonrowe.com/wp-content/uploads/2010/02/now_laterV21.png"><img src="http://jasonrowe.com/wp-content/uploads/2010/02/now_laterV21.png" alt="" title="now_laterV2" width="429" height="196" class="alignnone size-full wp-image-1015" /></a></p>
<p>The next snippet uses fixed point recursive scheduling. It follows this format <code>Schedule(Action&lt;Action(TimeSpan)&gt;,TimeSpan)</code></p>
<pre class="brush: c#; ">

        static void Main(string[] args)
        {
            var timespan = new TimeSpan(0, 0, 5);
            var scheduler = Scheduler.Default;

            using (scheduler.Schedule(Self =&gt;
               {
                   Console.WriteLine(&quot;recursive&quot;);
                   Self(timespan);

               }, timespan))
            {

                Console.WriteLine(&quot;type q to quit&quot;);
                while (Console.ReadLine() != &quot;q&quot;)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine(&quot;...&quot;);
                }
            }
        }
</pre>
<p>Here is the result from the recursive scheduler.</p>
<p><a href="http://jasonrowe.com/wp-content/uploads/2010/02/recursiveV21.png"><img src="http://jasonrowe.com/wp-content/uploads/2010/02/recursiveV21.png" alt="" title="recursiveV2" width="413" height="340" class="alignnone size-full wp-image-1014" /></a></p>
<p>In the video on IScheduler, it&#8217;s mentioned that a scheduler could be written to abstract away time. On CodePlex you can find a simple implementation of a virtual time scheduler <a href="http://rxpowertoys.codeplex.com/wikipage?title=TimeMachineScheduler&#038;referringTitle=Home">TimeMachineScheduler</a>.</p>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2010. |
<a href="http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/">Permalink</a> |
<a href="http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/&amp;title=System.Reactive IScheduler Hello World">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2010/02/08/system-reactive-ischeduler-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Replace a Universal Joint on 95 Dodge Ram</title>
		<link>http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/</link>
		<comments>http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 05:43:47 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Auto Repair]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=910</guid>
		<description><![CDATA[Pictured below is a broken Universal Joint.

The broken universal joint is in the middle of the picture with a missing cap. It&#8217;s the hole with grease coming out of it. When you are driving you will know it is broken because it will make a loud knocking noise.
Disclaimer: I recommend that you visit and seek [...]]]></description>
			<content:encoded><![CDATA[<p>Pictured below is a broken Universal Joint.<br />
<a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240371.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240371-300x225.jpg" alt="Broken Universal Joint" title="Broken Universal Joint" width="300" height="225" class="alignnone size-medium wp-image-913" /></a></p>
<p>The broken universal joint is in the middle of the picture with a missing cap. It&#8217;s the hole with grease coming out of it. When you are driving you will know it is broken because it will make a loud knocking noise.</p>
<p><em>Disclaimer: I recommend that you visit and seek the expertise of a mechanic before making any auto repairs. Therefore, I assume no responsibility for any problems, breakdowns, or accidents experienced from readers of this post. It is the responsibility of the individual to safely maintain his or her vehicle.</em></p>
<p><strong>Needed Tools:</strong></p>
<ol>
<li>Lift or Jack and Jack Stand</li>
<li>Lug Wrench</li>
<li>Socket Wrench and Set</li>
<li>Set of Hex Wrenches</li>
<li>Rubber Hammer</li>
<li>Hammer</li>
<li>Large Flat Head Screw Driver or Chisel</li>
</ol>
<p><strong>Replacement Steps</strong></p>
<p><strong>1.</strong> Loosen lug nuts on tire</p>
<p><strong>2.</strong> Lift or Jack vehicle. If you use a jack also use a jack stand.</p>
<p><strong>3.</strong> Remove brakes. On the Dodge Ram you will find two hex bolts on the back. </p>
<p><a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240372.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240372-300x225.jpg" alt="Hex Bolts on back of brakes" title="Hex Bolts on back of brakes" width="300" height="225" class="alignnone size-medium wp-image-921" /></a></p>
<p>You may need to use a large flat head screw driver to carefully pry around the edges to get it free. You will not need to disconnect the hoses. Set the braking system on the frame of the vehicle to get it out of the way.</p>
<p><strong>4.</strong> Remove the rotor. </p>
<p><strong>5.</strong> Remove bolts on back of wheel Bearing housing. It will have three bolts on the back side that you can remove with a 9/16 socket and wrench.<br />
<a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240373.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240373-300x225.jpg" alt="Removing Rotors Bolts" title="Removing Rotors Bolts" width="300" height="225" class="alignnone size-medium wp-image-924" /></a></p>
<p><strong>6.</strong> Carefully pull out the drive shaft by holding onto the wheel bearing housing and drive shaft. (if it&#8217;s stuck you may need to build a pulling attachment like this <a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240396.jpg">one</a>. That is beyond the scope of this post). You don&#8217;t need to remove the bearing housing. You must be careful when pulling out the drive shaft because inside is a rubber seal and you don&#8217;t want to tear it. Pull it out straight and gently to prevent causing major issues. </p>
<p><strong>7.</strong> Now that you have the drive shaft out of the vehicle. You will now want to remove all 4 clips (circled in red in the picture below) that are holding in the Universal Joint. Do this using a small screw driver and working under the edge and pry them out from one side.<br />
<a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240374.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240374-300x225.jpg" alt="" title="PC240374" width="300" height="225" class="alignnone size-medium wp-image-931" /></a></p>
<p><strong>8.</strong> Once all clips are removed you can pound out the old Universal Joint from the yoke. Spray some WD-40 on the old universal joint. Put a large heavy duty socket that is larger then the universal joint cap under it and on top of a piece of wood. On the side you are going to pound on, use another socket which is one size smaller then the cap. Use the smaller socket to pound down the Universal Joint into the larger socket. Then you can remove the cap. Do this on both sides and then pull it out and dispose of properly. </p>
<p><strong>9.</strong> Now you can take out the new Universal Joint from the packaging and remove the 4 caps and place them to the side. <em><strong>You need to be very careful with the Universal Joint caps because they have needle bearings in them which are only held in by grease.</strong></em></p>
<p><strong>10.</strong> Check inside the yoke (where you removed the old clips) for any metal burs. If you see any that might effect the new clips use a metal file to sand those down. Do the same for the areas that are attached to the drive shaft. <strong><em>Getting the new clips on tightly and secure are critical to making sure your Universal Joint does not come loose and break again.</em></strong></p>
<p><strong>11.</strong> With the caps off position the Universal Joint into the wheel bearing housing. Then carefully place the cap on one side over the Universal Joint.<strong> Make sure it is far enough down so the needle bearings cannot come out</strong>. Then using a rubber hammer to gently pound the cap and universal joint far enough in so you can put on the clip and the other sides cap. With the clip on now pound back the other way until it stops and you have enough room to put on the other sides clip. Repeat these steps for the portion that attaches to the drive shaft.</p>
<p><a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240380.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240380-300x225.jpg" alt="putting in Universal Joint clips" title="putting in Universal Joint clips" width="300" height="225" class="alignnone size-medium wp-image-940" /></a></p>
<p><strong>12.</strong> Before putting it back together put Anti-Seize on the bolts and portion where the wheel bearing connects. When putting the drive shaft back in do it carefully so you do not tear the rubber seals where it attaches inside the motor.</p>
<div id="attachment_948" class="wp-caption alignnone" style="width: 235px"><a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240384.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240384-225x300.jpg" alt="Anti-Seize" title="Anti-Seize" width="225" height="300" class="size-medium wp-image-948" /></a><p class="wp-caption-text">Anti-Seize</p></div>
<div id="attachment_951" class="wp-caption alignnone" style="width: 310px"><a href="http://jasonrowe.com/wp-content/uploads/2009/12/PC240394.jpg"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/PC240394-300x225.jpg" alt="Anti-Seize 2" title="Anti-Seize 2" width="300" height="225" class="size-medium wp-image-951" /></a><p class="wp-caption-text">Anti-Seize 2</p></div>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/">Permalink</a> |
<a href="http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/&amp;title=How to Replace a Universal Joint on 95 Dodge Ram">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/12/27/how-to-replace-u-joint/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Entity Framework &#8211; Code Only Looking Good (part 2)</title>
		<link>http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/</link>
		<comments>http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:19:53 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=855</guid>
		<description><![CDATA[In my initial post I tried out the &#8220;Code Only&#8221; methodology of Entity Framework. Taking the code only experiment a step further, I built a sample WCF service that queries and updates a table for holidays. You can download the project if you want to take a look. You can also browse and download the [...]]]></description>
			<content:encoded><![CDATA[<p>In my initial <a href="http://jasonrowe.com/2009/12/11/entity-framework-code-only/">post</a> I tried out the &#8220;Code Only&#8221; methodology of Entity Framework. Taking the code only experiment a step further, I built a sample WCF service that queries and updates a table for holidays. You can <a href="http://jasonrowe.com/code/ef/HolidayService.zip">download the project</a> if you want to take a look. You can also browse and download the project via <a href="http://github.com/JasonRowe/EF-CTP2-HolidayService/archives/master">github</a>.</p>
<p>The console application &#8220;HolidayService.GenerateSchema&#8221; is very similar to the first post. It&#8217;s used to create the initial sqlexpress database and put in some initial test data. I did try out a simple configuration using some <a href="http://blogs.msdn.com/alexj/archive/2009/10/14/code-only-best-practices.aspx">best practices from this site</a>.
</p>
<p>The WCF service has two methods. </p>
<p><pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;[ServiceContract]
&nbsp;&nbsp;&nbsp;&nbsp;public interface IHolidays
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[OperationContract]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IList&lt;Holiday&gt; GetHolidayDetails(DateTime startDate, DateTime endDate);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[OperationContract]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int AddHolidayDetails(DateTime date, string name);
&nbsp;&nbsp;&nbsp;&nbsp;}
</code></pre></p>
<p>
In the HolidayService I created a HolidayManager class for CRUD operations. It uses a GlobalContext class to build an EF HolidayModel ObjectContext. For example, this is what that GetHolidays method looks like in the manager.
</p>
<p><pre><code>
&nbsp;&nbsp;using (holidayContext)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp; var holidayQueryResult = (from h in holidayContext.Holidays
&nbsp;&nbsp;&nbsp;&nbsp; where h.HolidayDate &lt; endDate &amp; h.HolidayDate &gt; startDate select h);

&nbsp;&nbsp;&nbsp;&nbsp; foreach (var item in holidayQueryResult)
&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;holidays.Add(item);
&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;}
</code></pre></p>
<p>
In the GlobalContext class, is where my simple project started to feel some pain. It doesn&#8217;t feel right to be using a concrete version of the HolidayModel in the ContextBuilder which returns the ObjectContext. I also don&#8217;t like that the sql connection string and connection are all in this class. In another post, I&#8217;ll use some of the suggestions below to try to make this area more flexible.
</p>
<p><pre><code>
var builder = new ContextBuilder&lt;HolidayModel&gt;();
builder.Configurations.Add(new HolidayConfiguration());
var connStr = ConfigurationManager.ConnectionStrings[&quot;UserDBConn&quot;].ConnectionString;
var connection = new SqlConnection(connStr);
return builder.Create(connection);
</code></pre></p>
<p>
Since this is a small project I didn&#8217;t go any further to clean up the GlobalContext class. I&#8217;ll leave that for next time I look into code only. Below are some links which investigate managing ObjectContext, dynamic models, and using EF in a business architecture.
</p>
<ol>
<li><a href="http://dotnetslackers.com/articles/ado_net/managing-entity-framework-objectcontext-lifespan-and-scope-in-n-layered-asp-net-applications.aspx">Managing Entity Framework ObjectContext</a></li>
<li><a href="http://blogs.msdn.com/alexj/archive/2009/11/09/tip-42-how-to-create-a-dynamic-model-using-code-only.aspx">how to create a dynamic model using code only</a></li>
<li><a href="http://daniel.wertheim.se/2009/11/13/entity-framework-4-part-4-autoregister-entitymappings/">Daniel Wertheim &#8211; EfEntityStore</a></li>
<li><a href="http://daniel.wertheim.se/2009/12/20/updates-to-putting-entity-framework-4-to-use-in-a-business-architecture/">Putting Entity framework 4 to use in a business architecture</a></li>
<li><a href="http://blogs.taiga.nl/martijn/tag/entity-framework/">Repository implementation &#8211; Entity Framework 4.0: a fresh start </a></li>
</ol>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/">Permalink</a> |
<a href="http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/&amp;title=Entity Framework &#8211; Code Only Looking Good (part 2)">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/12/22/entity-framework-code-only-looking-good-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Entity Framework &#8211; Code Only Looking Good</title>
		<link>http://jasonrowe.com/2009/12/11/entity-framework-code-only/</link>
		<comments>http://jasonrowe.com/2009/12/11/entity-framework-code-only/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 22:53:36 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[Entity Framework]]></category>
		<category><![CDATA[.net4]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=765</guid>
		<description><![CDATA[I&#8217;ve been hearing rumors Entity Framework (EF) is more robust now. I did a few searches and found the latest version EF CTP2.  I was happy to find EF has a &#8220;code only&#8221; method for generating the database schema and a good take on configuration. 
If you are intrested in the code only method [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hearing rumors Entity Framework (EF) is more robust now. I did a few searches and found the latest version <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=13FDFCE4-7F92-438F-8058-B5B4041D0F01&#038;displayLang=en">EF CTP2.</a>  I was happy to find EF has a &#8220;code only&#8221; method for generating the database schema and a good take on configuration. </p>
<p>If you are intrested in the code only method check out this <a href="http://blogs.msdn.com/adonet/pages/feature-ctp-walkthrough-code-only-for-the-entity-framework.aspx">walk through</a>.  I went through it and built my own application to get a handle on this new feature. Here were the steps I took to get up and running.  You will need Visual Studio 2010, SQL, and CTP2 version of EF.</p>
<p><strong>1)</strong> Install <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=13FDFCE4-7F92-438F-8058-B5B4041D0F01&#038;displayLang=en">CTP2 Entity Framework Preview 2</a></p>
<p><a href="http://jasonrowe.com/2009/12/11/entity-framework-code-only/ctp2-2/" rel="attachment wp-att-792"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/ctp21-300x235.PNG" alt="ctp2" title="ctp2" width="300" height="235" class="alignnone size-medium wp-image-792" /></a></p>
<p><strong>2)</strong> Create a new class library project in your solution. This will be for your objects that will get mapped to the database.  I named mine &#8220;UserSchema&#8221;.  In this project you are just creating normal classes without any references to EF.  Below are the two classes I used for testing.  Notice they have no meta tags or any other tags that would be EF specific.</p>
<pre class="brush: c#; ">

   public class Profile
    {
        public Profile() { }
        public int ID { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string PermaUrl { get; set; }
        public DateTime Created { get; set; }
        public DateTime? LastSeen { get; set; }
    }

    public class User
    {
        public User() { }
        public int ID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string UserName { get; set; }
        public string Password {get; set;}
        public ICollection&lt;profile&gt; Profiles { get; set; }
    }
</pre>
<p><strong>3)</strong> Next create a new class project in your solution for your EF models.  I called mine UserManager.Model.  I think it is good to make a seperate project as this is going to setup all your class context for connecting to EF. You will also need to add a project reference to the project that has your objects which you want to be mapped in the database and a reference to Microsoft.Data.Entity.CTP and System.Data.Entity.</p>
<p><pre><pre>
public class UserModel : ObjectContext
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public UserModel(EntityConnection connection)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: base(connection)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefaultContainerName = &quot;UserModel&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public IObjectSet&lt;User&gt; User
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get { return base.CreateObjectSet&lt;User&gt;(); }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public IObjectSet&lt;Profile&gt; Profiles
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get { return base.CreateObjectSet&lt;Profile&gt;(); }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
</pre></pre></p>
<p><strong>4)</strong> Create a new console application to automatically generate your database.  I called mine &#8220;UserManager.GenerateDatabase&#8221;.  This is the application that will use the object context to autogenerate the database. You can also do specific table configuration and other initialization.  You can use a RegisterConfigurations method.  The walk through above goes into more detail on that.</p>
<p><pre><pre>
var builder = new ContextBuilder&lt;UserModel&gt;();
var connStr = ConfigurationManager.ConnectionStrings[&quot;UserDBConn&quot;].ConnectionString;

var connection = new SqlConnection(connStr);

using (var ctx = builder.Create(connection))
{
&nbsp;&nbsp;&nbsp;&nbsp;if (ctx.DatabaseExists())
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctx.DeleteDatabase();
&nbsp;&nbsp;&nbsp;&nbsp; ctx.CreateDatabase();
</pre></pre></p>
<p>My project and auto generated tables ended up looking like this:<br />
<a href="http://jasonrowe.com/wp-content/uploads/2009/12/sql_result1.png"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/sql_result1.png" alt="sql results from code only" title="sql_result" width="211" height="309" class="alignnone size-full wp-image-848" /></a></p>
<p><a href="http://jasonrowe.com/2009/12/11/entity-framework-code-only/efprojectsetup/" rel="attachment wp-att-784"><img src="http://jasonrowe.com/wp-content/uploads/2009/12/EFProjectSetup-262x300.PNG" alt="EFProjectSetup" title="EFProjectSetup" width="262" height="300" class="alignnone size-medium wp-image-784" /></a></p>
<p>So after going through this quick setup I got a taste of what is to come.  I&#8217;m still going to stick with ActiveRecord for my ORM but I think EF will definitly be an option in the future.  Also, the code only mode will be a little more comfortable for people who have an ActiveRecord background. </p>
<p><strong><em>update</em></strong> &#8211; <a href="/2009/12/22/entity-framework-code-only-looking-good-part-2/">Code Only Looking Good (part 2)</a></p>
<p>Entity Framework blog posts</p>
<ol>
<li><a href="http://blogs.msdn.com/efdesign/archive/2009/06/10/code-only.aspx">Code Only Announcement</a></li>
<li><a href="http://blogs.msdn.com/adonet/archive/2009/06/22/feature-ctp-walkthrough-code-only-for-entity-framework.aspx">Code Only Walk Through Entity FrameWork</a></li>
<li><a href="http://blogs.msdn.com/efdesign/archive/2009/08/03/code-only-enhancements.aspx">Code Only Enhancements</a></li>
<li><a href="http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx">Even More Code Only Enhancements!</a></li>
</ol>
</profile>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/12/11/entity-framework-code-only/">Permalink</a> |
<a href="http://jasonrowe.com/2009/12/11/entity-framework-code-only/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/12/11/entity-framework-code-only/&amp;title=Entity Framework &#8211; Code Only Looking Good">del.icio.us</a>
<br/>
Post tags: <a href="http://jasonrowe.com/tag/net4/" rel="tag">.net4</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/12/11/entity-framework-code-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ConvertBase C# Exercise</title>
		<link>http://jasonrowe.com/2009/09/20/convertbase-c-exercise/</link>
		<comments>http://jasonrowe.com/2009/09/20/convertbase-c-exercise/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 07:26:44 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.net]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=751</guid>
		<description><![CDATA[Quick function to convert a number from one base to another. This is just for fun and I&#8217;ve only tested it with a few conversions.


 static void Main(string[] args)
        {
            Console.WriteLine(ConvertBase(&#34;1&#34;, 2, 10));
     [...]]]></description>
			<content:encoded><![CDATA[<p>Quick function to convert a number from one base to another. This is just for fun and I&#8217;ve only tested it with a few conversions.</p>
<pre class="brush: c#; ">

 static void Main(string[] args)
        {
            Console.WriteLine(ConvertBase(&quot;1&quot;, 2, 10));
            Console.WriteLine(ConvertBase(&quot;10&quot;, 2, 10));
            Console.WriteLine(ConvertBase(&quot;11&quot;, 2, 10));
            Console.ReadLine();
        }

        public static string NumberToBaseString(string numberStr, int baseNum)
        {
            int number;

            if (!int.TryParse(numberStr, out number))
                return &quot;&quot;;

            if (number &lt; baseNum)

                return number.ToString();

            var rem = number % baseNum;
            var result = rem.ToString();
            var reducedNum = (number - rem) / baseNum;
            var restOfString = NumberToBaseString(reducedNum.ToString(), baseNum);
            return restOfString + result;
        }

        public static int BaseStringToValue(string digitString, int baseNum)
        {
            if (string.IsNullOrEmpty(digitString))
                return 0;

            var result = digitString.Remove(0, digitString.Length - 1);
            var remainingString = digitString.Remove(digitString.Length - 1, 1);
            var valueOfRemainingString = BaseStringToValue(remainingString, baseNum);
            return int.Parse(result) + (baseNum * valueOfRemainingString);
        }

        public static string ConvertBase(string numberString, int baseOrginal, int baseResult)
        {
            var number = BaseStringToValue(numberString, baseOrginal);
            return NumberToBaseString(number.ToString(), baseResult);
        }
</pre>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/09/20/convertbase-c-exercise/">Permalink</a> |
<a href="http://jasonrowe.com/2009/09/20/convertbase-c-exercise/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/09/20/convertbase-c-exercise/&amp;title=ConvertBase C# Exercise">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/09/20/convertbase-c-exercise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive LINQ Query Example</title>
		<link>http://jasonrowe.com/2009/09/19/recursive-linq-query-example/</link>
		<comments>http://jasonrowe.com/2009/09/19/recursive-linq-query-example/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 05:31:22 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=699</guid>
		<description><![CDATA[I found this Traverse extension post on MSDN while searching for a good recursion example in Linq. I know it&#8217;s a little dated but Hey! We all learn at our own pace and mine is a little sloooower when it comes to Linq
I really got a lot out of this code snippet in terms of patterns [...]]]></description>
			<content:encoded><![CDATA[<p>I found this <a href="http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/fe3d441d-1e49-4855-8ae8-60068b3ef741/">Traverse extension post</a> on MSDN while searching for a good recursion example in Linq. I know it&#8217;s a little dated but Hey! We all learn at our own pace and mine is a little sloooower when it comes to Linq</p>
<p>I really got a lot out of this code snippet in terms of patterns and syntax. It makes use of some goodies like Delegates, Linq, and IEnumerable. The most interesting part for me though was the recursive call inside the Traverse extension and what it was being used for.</p>
<p>It shows a good pattern for getting values out of nested objects or flatting. Here is a quick sample app using the Traverse extension. Below this I&#8217;ve posted some other sources with similar selection patterns. </p>
<p><a href="http://codepaste.net/gf3q5a" >Link to code with syntax highlighting</a></p>
<p></p>
<p><pre><pre>
class Program
{
static void Main()
{
&nbsp;&nbsp;&nbsp;&nbsp;var list = new List&lt;MyClass&gt; {new MyClass(10), new MyClass(20)};

&nbsp;&nbsp;&nbsp;&nbsp;foreach(var l in list)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l.MyList = new List&lt;MyClass&gt; {new MyClass(10)};
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;var total = list.Traverse(x =&gt; x.MyList).Sum(x =&gt; x.Val);

&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(total);
&nbsp;&nbsp;&nbsp;&nbsp;Console.ReadLine();
}
}
public static class MyExtensions
{
//The Traverse extension can be added to types of IEnumerable&lt;T&gt;.
//Returns T
//Input Param
//&quot;fnRecurse&quot; - delegate with one parameter T and returns IEnumerable&lt;T&gt;

public static IEnumerable&lt;T&gt; Traverse&lt;T&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (this IEnumerable&lt;T&gt; source, Func&lt;T, IEnumerable&lt;T&gt;&gt; fnRecurse)
{
&nbsp;&nbsp;&nbsp;&nbsp;foreach (T item in source)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yield return item;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var seqRecurse = fnRecurse(item);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (seqRecurse != null)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{

//Making Recursive call to Traverse using 
//results from the lambda expression 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach (T itemRecurse in Traverse(seqRecurse, fnRecurse))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yield return itemRecurse;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}
}

public class MyClass
{
public MyClass(int val)
{
&nbsp;&nbsp;&nbsp;&nbsp;Val = val;
}

public int Val;
public List&lt;MyClass&gt; MyList = new List&lt;MyClass&gt;();
}</pre></pre><br />
</p>
<p><b>Here are some more posts on the same topic: </b></p>
<ul>
<li><a href="http://www.pluralsight.com/community/blogs/jeffsch/archive/2006/08/18/33631.aspx">a recursive Linq Extentions</a> </li>
<li><a href="http://j832.com/workBlogFiles/2008-01-16_SelectRecursive.htm">Select Recursive</a> </li>
<li><a href="http://mutable.net/blog/archive/2008/05/23/using-linq-to-objects-for-recursion.aspx">Descendants extension</a> </li>
</ul>
<p></p>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/09/19/recursive-linq-query-example/">Permalink</a> |
<a href="http://jasonrowe.com/2009/09/19/recursive-linq-query-example/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/09/19/recursive-linq-query-example/&amp;title=Recursive LINQ Query Example">del.icio.us</a>
<br/>
Post tags: <a href="http://jasonrowe.com/tag/net/" rel="tag">.net</a>, <a href="http://jasonrowe.com/tag/learning/" rel="tag">learning</a>, <a href="http://jasonrowe.com/tag/snippet/" rel="tag">snippet</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/09/19/recursive-linq-query-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interview Programming Question &#8211; find perfect numbers</title>
		<link>http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/</link>
		<comments>http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 05:37:17 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Interview Question]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=691</guid>
		<description><![CDATA[Here is a problem I got once for a entry level programming job. I received lots of help from the person asking and it turned out to be a good experience. If you ever use this in an interview be nice because this really has little to do with real world programming and more about [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a problem I got once for a entry level programming job. I received lots of help from the person asking and it turned out to be a good experience. If you ever use this in an interview be nice because this really has little to do with real world programming and more about finding out about the person.</p>
<p><strong>Question</strong>: Create a method to find perfect numbers. In mathematics, a perfect number is defined as a positive integer which is the sum of its proper positive divisors</p>
<p><strong>Possible Answer:</strong></p>
<pre class="brush: c#; ">

class Program
{
static void Main()
{

for (int j = 1; j &lt; 10000; j++)
{
if (j % 2 == 0)
{
if (PerfectNumber.IsPerfectNumber(j))
Console.WriteLine(j + &quot;is perfect&quot;);
}
}
Console.ReadLine();
}
}

public static class PerfectNumber
{
public static bool IsPerfectNumber(int n)
{
var totalFactor = 0;
for (var i = 1; i &lt; n; i++)
{
if(n % i == 0)
{
totalFactor = totalFactor + i;
}
}

return totalFactor == n;
}
}
</pre>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/">Permalink</a> |
<a href="http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/&amp;title=Interview Programming Question &#8211; find perfect numbers">del.icio.us</a>
<br/>
Post tags: <a href="http://jasonrowe.com/tag/interview-question/" rel="tag">Interview Question</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/09/15/interview-programming-question-i-was-asked-once/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turing&#8217;s Lambda Notation</title>
		<link>http://jasonrowe.com/2009/09/05/turings-lambda-notation/</link>
		<comments>http://jasonrowe.com/2009/09/05/turings-lambda-notation/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 06:50:26 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Lambda]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=642</guid>
		<description><![CDATA[I&#8217;m still working through Turing&#8217;s paper on Computability and the Turing Machine.  I am at the end and reading the appendix on Alonzo Church&#8217;s equivalent approach using Lambda Calculus.   His work is so familiar to most programmers since we use the concepts in C, C++, Java, and C#.   I decided to use C# [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still working through Turing&#8217;s paper on Computability and the Turing Machine.  I am at the end and reading the appendix on Alonzo Church&#8217;s equivalent approach using Lambda Calculus.   His work is so familiar to most programmers since we use the concepts in C, C++, Java, and C#.   I decided to use C# Lambda syntax to get familiar before reading through the rest of the paper.</p>
<p><a rel="attachment wp-att-658" href="http://jasonrowe.com/2009/09/05/turings-lambda-notation/lambda_math_syntax-2/"><img class="alignnone size-full wp-image-658" title="lambda_math_syntax" src="http://jasonrowe.com/wp-content/uploads/2009/09/lambda_math_syntax.PNG" alt="lambda_math_syntax" width="537" height="136" /></a></p>
<p>I started simply and considered how I could make the following expression be represented by M.</p>
<p><strong>Math.Pow(x, 2.0) + 5 * x + 7</strong></p>
<p>Most commonly we see it in this form when programming.</p>
<pre class="brush: c#; ">

static double F(double x)
{

return Math.Pow(x, 2.0) + 5 * x + 7;

}
</pre>
<p>So convert it to a lambda expression.</p>
<pre class="brush: c#; ">

OneV firstExp = x =&gt; Math.Pow(x, 2.0) + 5 * x + 7;
</pre>
<p>where OneV is defined as (not suprisingly)</p>
<pre class="brush: c#; ">

delegate double OneV(double x);
</pre>
<p>In C# the two variable syntax could be something like this:</p>
<pre class="brush: c#; ">

TwoV Exp = (x, y) =&gt; Math.Pow(y, 2.0) + 5 * y + 18 * x + 2 * x * y + 7;
</pre>
<p>So thats how I got my head around the very basic syntax.</p>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/09/05/turings-lambda-notation/">Permalink</a> |
<a href="http://jasonrowe.com/2009/09/05/turings-lambda-notation/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/09/05/turings-lambda-notation/&amp;title=Turing&#8217;s Lambda Notation">del.icio.us</a>
<br/>
Post tags: <a href="http://jasonrowe.com/tag/lambda/" rel="tag">Lambda</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/09/05/turings-lambda-notation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intro to Propositional Logic Using C#</title>
		<link>http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/</link>
		<comments>http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 03:18:20 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Propositional Logic]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=628</guid>
		<description><![CDATA[I&#8217;ve been reading about propositional (or sentential) logic in the book &#8220;The Annotated Turing&#8221;.  I put together a quick console app to write out truth tables. It helped me get the hang of the mathematical notation &#8220;v&#8221;, &#8220;&#038;&#8221;, and &#8220;->&#8221;. In C# those would be &#124;&#124;, &#038;&#038;, and !x &#124;&#124; y respectively. I hope [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading about propositional (or sentential) logic in the book &#8220;The Annotated Turing&#8221;.  I put together a quick console app to write out truth tables. It helped me get the hang of the mathematical notation &#8220;v&#8221;, &#8220;&#038;&#8221;, and &#8220;->&#8221;. In C# those would be ||, &#038;&#038;, and !x || y respectively. I hope someone else finds it useful.</p>
<pre class="brush: c#; ">

using System;
using System.Collections.Generic;

namespace PropositionalLogic
{
    public class Program
    {
        public class truthvalue
        {
            public bool X { get; set; }
            public bool Y { get; set; }
        }

        public static bool XorY(bool x, bool y)
        {
            return (x || y);
        }

        public static bool XandY(bool x, bool y)
        {
            return (x &amp;&amp; y);
        }

        public static bool Exclusive(bool x, bool y)
        {
            return (x &amp;&amp; y) &amp;&amp; !(x &amp;&amp; y);// always false
        }

        public static bool Tautoloty(bool x, bool y)
        {
            return x || y || (!x &amp;&amp; !y);// always true
        }

        public static bool Contradition(bool x, bool y)
        {
            return x || (y &amp;&amp; !y);
        }

        public static bool MaterialImplication(bool x, bool y)
        {
            return !x || y; //this can also be expressed as the following conjunction !(x &amp;&amp; !y);
        }

        public static bool BiConditional(bool x, bool y)
        {
            return MaterialImplication(x, y) &amp;&amp; MaterialImplication(y, x); //&quot;if and only if&quot;
        }

        static void Main(string[] args)
        {
            var truthTable = new List&lt;truthvalue&gt;
                                 {
                                     new truthvalue() {X = false, Y = false},
                                     new truthvalue() {X = false, Y = true},
                                     new truthvalue() {X = true, Y = false},
                                     new truthvalue() {X = true, Y = true}
                                 };

            var sentences = new Dictionary&lt;string , Func&lt;bool, bool, bool&gt;&gt;
                                {
                                    {&quot;X v Y&quot;, XorY},
                                    {&quot;X &amp; Y&quot;, XandY},
                                    {&quot;(x v y)&amp; -(x &amp; y)&quot;, Exclusive},
                                    {&quot;x v y v (-x &amp; -y)&quot;, Tautoloty},
                                    {&quot;x -&gt; y&quot;, MaterialImplication},
                                    {&quot;x ~ y&quot;, BiConditional}
                                };

            CalculateTruthTable(truthTable, sentences);

            Console.ReadLine();
        }

        private static void CalculateTruthTable(IEnumerable&lt;truthvalue&gt; truthTable, Dictionary&lt;string , Func&lt;bool, bool, bool&gt;&gt; sentences)
        {
            foreach (var sentence in sentences)
            {
                Console.WriteLine(&quot;&quot;);
                Console.WriteLine(&quot;|X      |Y      |{0}  |&quot;, sentence.Key);

                foreach (var value in truthTable)
                {
                    var x = value.X;
                    var y = value.Y;

                    var result = sentence.Value(x, y);

                    Console.WriteLine(&quot;|{0}  |{1}  |{2}  |&quot;, PrettyPrint(x), PrettyPrint(y), PrettyPrint(result));
                }
            }
        }

        private static string PrettyPrint(bool input)
        {
            return input ? input + &quot; &quot; : input.ToString();
        }
    }
}
</pre>
<p></string></truthvalue></string></truthvalue>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/">Permalink</a> |
<a href="http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/&amp;title=Intro to Propositional Logic Using C#">del.icio.us</a>
<br/>
Post tags: <a href="http://jasonrowe.com/tag/c/" rel="tag">C#</a>, <a href="http://jasonrowe.com/tag/math/" rel="tag">Math</a>, <a href="http://jasonrowe.com/tag/propositional-logic/" rel="tag">Propositional Logic</a><br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/08/28/intro-to-propositional-logic-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Active Tab Menu Pattern</title>
		<link>http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/</link>
		<comments>http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 04:49:09 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jasonrowe.com/?p=615</guid>
		<description><![CDATA[I was just messing with PHP and made this simple little script to track which menu item is active. It looks at the last URL folder name to make the match. For example, if the URL was &#8220;http://localhost/example/About/&#8221; it would match &#8220;about&#8221; and write out the needed css. It also works correctly with the URL [...]]]></description>
			<content:encoded><![CDATA[<p>I was just messing with PHP and made this simple little script to track which menu item is active. It looks at the last URL folder name to make the match. For example, if the URL was &#8220;http://localhost/example/About/&#8221; it would match &#8220;about&#8221; and write out the needed css. It also works correctly with the URL http://localhost/example/About/index.php by stripping off the index.php value and looking at the folder about.</p>
<pre class="brush: php; ">

&lt; ?php

$folderName = basename($_SERVER[&#039;REQUEST_URI&#039;]);

if(strtoupper($folderName) == &quot;INDEX.PHP&quot;)
{

$folderName = dirname ($_SERVER[&#039;REQUEST_URI&#039;]);
$paths = explode(&#039;/&#039;, $folderName);

foreach($paths as $key =&gt; $value)
{
if(!empty($value))
{
$new_paths[] = $value;
}
}

$last_path = $new_paths[count($new_paths) - 1];
$folderName = $last_path;
}

function getCSSName($str,$folderName)
{
//echo $str;
//echo $folderName;

if ($str == $folderName)
echo &quot;current_page_item&quot;;
}

?&gt;
</pre>
<p>Then a quick example of using it in the html.</p>
<pre class="brush: html; ">

&lt;ul id=&quot;tabs&quot;&gt;
&lt;li class=&quot;home-item &lt;?php getCSSName(&quot;EXAMPLE&quot;, strtoupper($folderName)); ?&gt;&quot;&gt;
&lt;a rel=&quot;nofollow&quot; title=&quot;home&quot; href=&quot;http://localhost/example/&quot;&gt;Home&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;page-item-1 &lt;?php getCSSName(&quot;ABOUT&quot;, strtoupper($folderName)); ?&gt;&quot;&gt;
&lt;a title=&quot;About&quot; href=&quot;http://localhost/example/About/&quot;&gt;About&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;page-item-2 &lt;?php getCSSName(&quot;SERVICES&quot;, strtoupper($folderName)); ?&gt;&quot;&gt;
&lt;a title=&quot;Services&quot; href=&quot;http://localhost/example/services/&quot;&gt;Services&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;page-item-3 &lt;?php getCSSName(&quot;CONTACT&quot;, strtoupper($folderName)); ?&gt;&quot;&gt;
&lt;a title=&quot;Services&quot; href=&quot;http://localhost/example/contact/&quot;&gt;Contact&lt;/a&gt;
&lt;/li&gt;
&lt;li class=&quot;page-item-4 &lt;?php getCSSName(&quot;PICTURES&quot;, strtoupper($folderName)); ?&gt;&quot;&gt;
&lt;a title=&quot;Services&quot; href=&quot;http://localhost/example/pictures/&quot;&gt;Pictures&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
</pre>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 704px; width: 1px; height: 1px;">&lt;ul id=&#8221;tabs&#8221;&gt;<br />
&lt;li class=&#8221;home-item &lt;?php getCSSName(&#8220;AS&#8221;, strtoupper($folderName)); ?&gt;&#8221;&gt;<br />
&lt;a rel=&#8221;nofollow&#8221; title=&#8221;http://localhost/as/&#8221; href=&#8221;http://localhost/as/&#8221;&gt;Home&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li class=&#8221;page-item-1 &lt;?php getCSSName(&#8220;ABOUT&#8221;, strtoupper($folderName)); ?&gt;&#8221;&gt;<br />
&lt;a title=&#8221;About&#8221; href=&#8221;http://localhost/as/About/&#8221;&gt;About&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li class=&#8221;page-item-2 &lt;?php getCSSName(&#8220;SERVICES&#8221;, strtoupper($folderName)); ?&gt;&#8221;&gt;<br />
&lt;a title=&#8221;Services&#8221; href=&#8221;http://localhost/as/services/&#8221;&gt;Services&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li class=&#8221;page-item-3 &lt;?php getCSSName(&#8220;CONTACT&#8221;, strtoupper($folderName)); ?&gt;&#8221;&gt;<br />
&lt;a title=&#8221;Services&#8221; href=&#8221;http://localhost/as/contact/&#8221;&gt;Contact&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li class=&#8221;page-item-4 &lt;?php getCSSName(&#8220;PICTURES&#8221;, strtoupper($folderName)); ?&gt;&#8221;&gt;<br />
&lt;a title=&#8221;Services&#8221; href=&#8221;http://localhost/as/pictures/&#8221;&gt;Pictures&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li class=&#8221;rss&#8221;&gt;<br />
&lt;a rel=&#8221;nofollow&#8221; title=&#8221;contact information 763-783-0708&#8243; href=&#8221;contact&#8221;&gt;&lt;b&gt;Call Now 763.783.0708&lt;/b&gt;&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;/ul&gt;</div>
<hr />
<p><small>&copy; admin for <a href="http://jasonrowe.com">Jason Rowe</a>, 2009. |
<a href="http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/">Permalink</a> |
<a href="http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/&amp;title=PHP Active Tab Menu Pattern">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jasonrowe.com/2009/08/15/php-active-tab-menu-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
