<?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>Sam Beauvois &#187; Uncategorized</title>
	<atom:link href="http://www.sambeauvois.be/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sambeauvois.be/blog</link>
	<description>general dev, .net and other stuff</description>
	<lastBuildDate>Tue, 31 Jan 2012 13:38:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Bring a bit of the Subsonic power to Entity Framework by adding automatic audit and logical delete fields</title>
		<link>http://www.sambeauvois.be/blog/2011/11/bring-a-bit-of-the-subsonic-power-to-entity-framework-by-adding-automatic-audit-and-logical-delete-fields/</link>
		<comments>http://www.sambeauvois.be/blog/2011/11/bring-a-bit-of-the-subsonic-power-to-entity-framework-by-adding-automatic-audit-and-logical-delete-fields/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 16:04:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[SubSonic]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=915</guid>
		<description><![CDATA[Here is the code to do the same thing than in my previous article &#8220;Bring a bit of the Subsonic power to Linq to sql by adding automatic audit and logical delete fields&#8221; namespace YouNamespace.DAL { using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Data.Common; using System.Data.Objects; using System.Linq; public partial class [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the code to do the same thing than in my previous article <a href="http://www.sambeauvois.be/blog/2010/09/bring-a-bit-of-the-subsonic-power-to-linq-to-sql-by-adding-automatic-audit-and-logical-delete-fields/" target="_blank">&#8220;Bring a bit of the Subsonic power to Linq to sql by adding automatic audit and logical delete fields&#8221;</a></p>
<pre class="brush: csharp; title: ;">

namespace YouNamespace.DAL
{
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Data;
 using System.Data.Common;
 using System.Data.Objects;
 using System.Linq;

 public partial class YOURCONTEXTEntities
 {
 /// &lt;summary&gt;
 /// System fields for automatic audit and logical delete
 /// &lt;/summary&gt;
 private struct SystemFields
 {
 public const string CreatedOn = &quot;CREATEDON&quot;;
 public const string ModifiedOn = &quot;MODIFIEDON&quot;;
 public const string CreatedBy = &quot;CREATEDBY&quot;;
 public const string ModifiedBy = &quot;MODIFIEDBY&quot;;
 public const string IsDeleted = &quot;ISDELETED&quot;;
 }

 /// &lt;summary&gt;
 /// Overriding the SaveChanges method to automaticaly set system fields if any.
 /// &lt;/summary&gt;
 /// &lt;param name=&quot;options&quot;&gt;&lt;/param&gt;
 /// &lt;returns&gt;&lt;/returns&gt;
 public override int SaveChanges(System.Data.Objects.SaveOptions options)
 {
 IEnumerable&lt;ObjectStateEntry&gt; newEntries = this.ObjectStateManager.GetObjectStateEntries(EntityState.Added);

 foreach (ObjectStateEntry entry in newEntries)
 {
 ReadOnlyCollection&lt;FieldMetadata&gt; fieldsMetaData = entry.CurrentValues
 .DataRecordInfo.FieldMetadata;

 FieldMetadata createdOnField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.CreatedOn, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (createdOnField.FieldType != null)
 {
 entry.CurrentValues.SetValue(createdOnField.Ordinal, DateTime.Now);
 }

 FieldMetadata createdByField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.CreatedBy, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (createdByField.FieldType != null)
 {
 entry.CurrentValues.SetValue(createdByField.Ordinal, &quot;Sam&quot;);
 }

 FieldMetadata deletedField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.IsDeleted, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (deletedField.FieldType != null)
 {
 entry.CurrentValues.SetValue(deletedField.Ordinal, false);
 }
 }

 IEnumerable&lt;ObjectStateEntry&gt; modifiedEntries = this.ObjectStateManager.GetObjectStateEntries(EntityState.Modified);
 foreach (ObjectStateEntry entry in modifiedEntries)
 {
 ReadOnlyCollection&lt;FieldMetadata&gt; fieldsMetaData = entry.CurrentValues
 .DataRecordInfo.FieldMetadata;

 FieldMetadata createdOnField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.ModifiedOn, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (createdOnField.FieldType != null)
 {
 entry.CurrentValues.SetValue(createdOnField.Ordinal, DateTime.Now);
 }

 FieldMetadata createdByField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.ModifiedBy, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (createdByField.FieldType != null)
 {
 entry.CurrentValues.SetValue(createdByField.Ordinal, &quot;Sam&quot;);
 }
 }

 IEnumerable&lt;ObjectStateEntry&gt; deletedEntries = this.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted);
 foreach (ObjectStateEntry entry in deletedEntries)
 {
 // change from deleted to modified (!important)
 this.ObjectStateManager.ChangeObjectState(entry.Entity, EntityState.Modified);

 ReadOnlyCollection&lt;FieldMetadata&gt; fieldsMetaData = entry.CurrentValues
 .DataRecordInfo.FieldMetadata;

 FieldMetadata deletedField = fieldsMetaData
 .Where(f =&gt; string.Equals(f.FieldType.Name, SystemFields.IsDeleted, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

 if (deletedField.FieldType != null)
 {
 entry.CurrentValues.SetValue(deletedField.Ordinal, true);
 }
else
 {
 // change back from modified to deleted (!important)
 this.ObjectStateManager.ChangeObjectState(entry.Entity, EntityState.Deleted);
 }
 }

 return base.SaveChanges(options);
 }
 }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2011/11/bring-a-bit-of-the-subsonic-power-to-entity-framework-by-adding-automatic-audit-and-logical-delete-fields/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>You Owe Me : first version</title>
		<link>http://www.sambeauvois.be/blog/2009/11/you-owe-me-first-version/</link>
		<comments>http://www.sambeauvois.be/blog/2009/11/you-owe-me-first-version/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 22:36:43 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=99</guid>
		<description><![CDATA[“You Owe Me” is a web application I made. It allows people to manage their debts and loans with their co-workers. It requires an IIS server configured with windows authentication, and .NET Framework 3.5 installed on the server. Functionalities: User management: First time the user access to the web application, he is inserted in the [...]]]></description>
			<content:encoded><![CDATA[<p>“You Owe Me” is a web application I made.</p>
<p>It allows people to manage their debts and loans with their co-workers.</p>
<p>It requires an IIS server configured with windows authentication, and .NET Framework 3.5 installed on the server.</p>
<h2>Functionalities:</h2>
<h3>User management:</h3>
<p>First time the user access to the web application, he is inserted in the system, but every user can modify the display name and the mail address.</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_users.png"><img style="border: 0px none;" src="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_users_thumb.png" border="0" alt="yom_users" width="244" height="197" /></a></p>
<h3>My Debts:</h3>
<p>User can add a debt, or say that he has refunded the lender</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_mydebts.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_mydebts_thumb.png" border="0" alt="yom_mydebts" width="244" height="206" /></a></p>
<h3>My loans:</h3>
<p>User can add a loan, or say that the borrower has refunded him</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_myloans.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_myloans_thumb.png" border="0" alt="yom_myloans" width="244" height="186" /></a></p>
<h3>All debts:</h3>
<p>An overview of all the current debts in the system (public debts only)</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_alldebts.png"><img style="border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px" src="http://www.sambeauvois.be/blog/wp-content/uploads/2009/11/yom_alldebts_thumb.png" border="0" alt="yom_alldebts" width="244" height="133" /></a></p>
<h2>How to get this application?</h2>
<p>This application is available for free on codeplex : <a href="http://yom.codeplex.com">http://yom.codeplex.com</a></p>
<h2>Technologies</h2>
<p>To build this application, I used :</p>
<ul>
<li>Microsoft .NET Framework 3.5</li>
<li>ASP.NET, C# Code</li>
<li>Subsonic</li>
<li>ELMAH</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2009/11/you-owe-me-first-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://www.sambeauvois.be/blog/2009/10/hello-world/</link>
		<comments>http://www.sambeauvois.be/blog/2009/10/hello-world/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 21:14:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WebSites]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=1</guid>
		<description><![CDATA[First post of my brand new blog. On this blog I&#8217;ll put some technical informations, and other stuff&#8230;]]></description>
			<content:encoded><![CDATA[<p>First post of my brand new blog.</p>
<p>On this blog I&#8217;ll put some technical informations, and other stuff&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2009/10/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

