<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments for Graeme Hill's Dev Blog</title>
	<atom:link href="http://graemehill.ca/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://graemehill.ca</link>
	<description></description>
	<pubDate>Sun, 05 Feb 2012 16:25:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Discard changes in LINQ to SQL DataContext by Reza</title>
		<link>http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/comment-page-1#comment-3008</link>
		<dc:creator>Reza</dc:creator>
		<pubDate>Mon, 30 Jan 2012 08:33:21 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=5#comment-3008</guid>
		<description>Compelete code of my Datacontext:


using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;

namespace DataContextDiscardChanges
{
    partial class NorthwindDataContext
    {
        #region Public Members

        public void DiscardChanges()
        {
            this.DiscardUpdates();
            this.DiscardInserts();
            this.DiscardDeletes();
        }

        public void DiscardInserts(Func predicate = null)
        {
            if (predicate != null)
                discardInserts(this.GetChangeSet().Inserts.OfType().Where(predicate));
            else
                discardInserts(this.GetChangeSet().Inserts.OfType());
        }

        public void DiscardInserts()
        {
            discardInserts(this.GetChangeSet().Inserts);
        }

        public void DiscardDeletes(Func predicate = null)
        {
            if (predicate != null)
                discardDeletes(this.GetChangeSet().Deletes.OfType().Where(predicate));
            else
                discardDeletes(this.GetChangeSet().Deletes.OfType());
        }

        public void DiscardDeletes()
        {
            discardDeletes(this.GetChangeSet().Deletes);
        }

        public void DiscardUpdates(Func predicate = null)
        {
            if (predicate != null)
                discardUpdates(this.GetChangeSet().Updates.OfType().Where(predicate));
            else
                discardUpdates(this.GetChangeSet().Updates.OfType());
        }

        public void DiscardUpdates()
        {
            discardUpdates(this.GetChangeSet().Updates);
        }

        #endregion Public Members

        #region Private Memebers

        private void discardInserts(IEnumerable insertedEntities)
        {
            foreach (var insertedItem in insertedEntities)
            {
                this.GetTable(insertedItem.GetType()).DeleteOnSubmit(insertedItem);
            }
        }

        private void discardDeletes(IEnumerable deletedEntities)
        {
            foreach (var deletedItem in deletedEntities)
            {
                this.GetTable(deletedItem.GetType()).InsertOnSubmit(deletedItem);
            }
        }

        private void discardUpdates(IEnumerable updatedEntities)
        {
            foreach (var updatedItem in updatedEntities)
            {
                ModifiedMemberInfo[] modifiedMembers = this.GetTable(updatedItem.GetType()).GetModifiedMembers(updatedItem);

                foreach (var modifiedMember in modifiedMembers)
                {
                    updatedItem.GetType().GetProperty(modifiedMember.Member.Name).SetValue(updatedItem, modifiedMember.OriginalValue, null);
                }
            }
        }

        #endregion Private Memebers
    }
}</description>
		<content:encoded><![CDATA[<p>Compelete code of my Datacontext:</p>
<p>using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Data.Linq;<br />
using System.Linq;</p>
<p>namespace DataContextDiscardChanges<br />
{<br />
    partial class NorthwindDataContext<br />
    {<br />
        #region Public Members</p>
<p>        public void DiscardChanges()<br />
        {<br />
            this.DiscardUpdates();<br />
            this.DiscardInserts();<br />
            this.DiscardDeletes();<br />
        }</p>
<p>        public void DiscardInserts(Func predicate = null)<br />
        {<br />
            if (predicate != null)<br />
                discardInserts(this.GetChangeSet().Inserts.OfType().Where(predicate));<br />
            else<br />
                discardInserts(this.GetChangeSet().Inserts.OfType());<br />
        }</p>
<p>        public void DiscardInserts()<br />
        {<br />
            discardInserts(this.GetChangeSet().Inserts);<br />
        }</p>
<p>        public void DiscardDeletes(Func predicate = null)<br />
        {<br />
            if (predicate != null)<br />
                discardDeletes(this.GetChangeSet().Deletes.OfType().Where(predicate));<br />
            else<br />
                discardDeletes(this.GetChangeSet().Deletes.OfType());<br />
        }</p>
<p>        public void DiscardDeletes()<br />
        {<br />
            discardDeletes(this.GetChangeSet().Deletes);<br />
        }</p>
<p>        public void DiscardUpdates(Func predicate = null)<br />
        {<br />
            if (predicate != null)<br />
                discardUpdates(this.GetChangeSet().Updates.OfType().Where(predicate));<br />
            else<br />
                discardUpdates(this.GetChangeSet().Updates.OfType());<br />
        }</p>
<p>        public void DiscardUpdates()<br />
        {<br />
            discardUpdates(this.GetChangeSet().Updates);<br />
        }</p>
<p>        #endregion Public Members</p>
<p>        #region Private Memebers</p>
<p>        private void discardInserts(IEnumerable insertedEntities)<br />
        {<br />
            foreach (var insertedItem in insertedEntities)<br />
            {<br />
                this.GetTable(insertedItem.GetType()).DeleteOnSubmit(insertedItem);<br />
            }<br />
        }</p>
<p>        private void discardDeletes(IEnumerable deletedEntities)<br />
        {<br />
            foreach (var deletedItem in deletedEntities)<br />
            {<br />
                this.GetTable(deletedItem.GetType()).InsertOnSubmit(deletedItem);<br />
            }<br />
        }</p>
<p>        private void discardUpdates(IEnumerable updatedEntities)<br />
        {<br />
            foreach (var updatedItem in updatedEntities)<br />
            {<br />
                ModifiedMemberInfo[] modifiedMembers = this.GetTable(updatedItem.GetType()).GetModifiedMembers(updatedItem);</p>
<p>                foreach (var modifiedMember in modifiedMembers)<br />
                {<br />
                    updatedItem.GetType().GetProperty(modifiedMember.Member.Name).SetValue(updatedItem, modifiedMember.OriginalValue, null);<br />
                }<br />
            }<br />
        }</p>
<p>        #endregion Private Memebers<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Discard changes in LINQ to SQL DataContext by Reza</title>
		<link>http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/comment-page-1#comment-3007</link>
		<dc:creator>Reza</dc:creator>
		<pubDate>Sun, 29 Jan 2012 12:07:42 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=5#comment-3007</guid>
		<description>hello every body

Discard Updated with Refresh method, reads orginal data from database and it's not good way to Discard in-memory objects

i'm using reflection to solve this problem:


public void DiscardUpdates()
        {
            var changeSet = this.GetChangeSet();
            foreach (var updatedItem in changeSet.Updates)
            {
                ModifiedMemberInfo[] modifiedMembers = this.GetTable(updatedItem.GetType()).GetModifiedMembers(updatedItem);

                foreach (var modifiedMember in modifiedMembers)
                {
                    updatedItem.GetType().GetProperty(modifiedMember.Member.Name).SetValue(updatedItem, modifiedMember.OriginalValue, null);
                }
            }
        }</description>
		<content:encoded><![CDATA[<p>hello every body</p>
<p>Discard Updated with Refresh method, reads orginal data from database and it&#8217;s not good way to Discard in-memory objects</p>
<p>i&#8217;m using reflection to solve this problem:</p>
<p>public void DiscardUpdates()<br />
        {<br />
            var changeSet = this.GetChangeSet();<br />
            foreach (var updatedItem in changeSet.Updates)<br />
            {<br />
                ModifiedMemberInfo[] modifiedMembers = this.GetTable(updatedItem.GetType()).GetModifiedMembers(updatedItem);</p>
<p>                foreach (var modifiedMember in modifiedMembers)<br />
                {<br />
                    updatedItem.GetType().GetProperty(modifiedMember.Member.Name).SetValue(updatedItem, modifiedMember.OriginalValue, null);<br />
                }<br />
            }<br />
        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Discard changes in LINQ to SQL DataContext by Andre</title>
		<link>http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/comment-page-1#comment-2996</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Fri, 13 Jan 2012 14:00:32 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=5#comment-2996</guid>
		<description>It's an incredible article. It's such a simple solution for all my problems with discarding data contexts. 

Thanks so much!</description>
		<content:encoded><![CDATA[<p>It&#8217;s an incredible article. It&#8217;s such a simple solution for all my problems with discarding data contexts. </p>
<p>Thanks so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Exporting armature animation with the Blender 2.5 Python API by davyzhang</title>
		<link>http://graemehill.ca/exporting-armature-animation-with-the-blender-25-python-api/comment-page-1#comment-2994</link>
		<dc:creator>davyzhang</dc:creator>
		<pubDate>Fri, 13 Jan 2012 07:52:16 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=364#comment-2994</guid>
		<description>this is a life saver article! thank you so much !</description>
		<content:encoded><![CDATA[<p>this is a life saver article! thank you so much !</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++ const correctness beats the .NET/Java alternatives by Ari Eisinger</title>
		<link>http://graemehill.ca/c-const-correctness-beats-the-netjava-alternatives/comment-page-1#comment-2991</link>
		<dc:creator>Ari Eisinger</dc:creator>
		<pubDate>Mon, 09 Jan 2012 04:19:19 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=407#comment-2991</guid>
		<description>Sorry:  I was thinking of using a read-only interface when I wrote the above, not a subclass.  The actual type of the object could be determined using RTTI, and the read-only subclass could be upcast to its writeable superclass.

With a read-only subclass, it seems to me that all you'd have to do would be to upcast and then you could use all the base class's functions including the ones that modify the object.

Anyway, it seems to require considerable gyrations to do this kind of thing, which in C++, as you say, can be done with the use of a single keyword.</description>
		<content:encoded><![CDATA[<p>Sorry:  I was thinking of using a read-only interface when I wrote the above, not a subclass.  The actual type of the object could be determined using RTTI, and the read-only subclass could be upcast to its writeable superclass.</p>
<p>With a read-only subclass, it seems to me that all you&#8217;d have to do would be to upcast and then you could use all the base class&#8217;s functions including the ones that modify the object.</p>
<p>Anyway, it seems to require considerable gyrations to do this kind of thing, which in C++, as you say, can be done with the use of a single keyword.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C++ const correctness beats the .NET/Java alternatives by Ari Eisinger</title>
		<link>http://graemehill.ca/c-const-correctness-beats-the-netjava-alternatives/comment-page-1#comment-2990</link>
		<dc:creator>Ari Eisinger</dc:creator>
		<pubDate>Mon, 09 Jan 2012 03:59:22 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=407#comment-2990</guid>
		<description>I recently realized that, due to RTTI in C#, a read-only subclass can be upcasted to its parent.  In other words, the read-only version here does not hide the writeable version it's supposed to protect.  It seems to me therefore that what is required is not just a subclass but a wrapper class with a private member that just forwards the calls to the member.  Yick!

I agree that the lack of const references and const pointers in Java and C# is a big drawback.</description>
		<content:encoded><![CDATA[<p>I recently realized that, due to RTTI in C#, a read-only subclass can be upcasted to its parent.  In other words, the read-only version here does not hide the writeable version it&#8217;s supposed to protect.  It seems to me therefore that what is required is not just a subclass but a wrapper class with a private member that just forwards the calls to the member.  Yick!</p>
<p>I agree that the lack of const references and const pointers in Java and C# is a big drawback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on LINQ to SQL Gotcha #5: Column Default Values by Brink</title>
		<link>http://graemehill.ca/linq-to-sql-gotcha-5-column-default-values/comment-page-1#comment-2959</link>
		<dc:creator>Brink</dc:creator>
		<pubDate>Wed, 21 Dec 2011 22:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=246#comment-2959</guid>
		<description>This is even later but szilardd answer works only if you never want to change the value. Throws an exception if you attempt to change the value.</description>
		<content:encoded><![CDATA[<p>This is even later but szilardd answer works only if you never want to change the value. Throws an exception if you attempt to change the value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Discard changes in LINQ to SQL DataContext by Usman</title>
		<link>http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/comment-page-1#comment-2879</link>
		<dc:creator>Usman</dc:creator>
		<pubDate>Tue, 29 Nov 2011 23:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=5#comment-2879</guid>
		<description>Thanks! Good to know this exists! My small blogpost on this
http://usman-suglatwala.blogspot.com/2011/11/discarding-changes-in-linq-memory.html</description>
		<content:encoded><![CDATA[<p>Thanks! Good to know this exists! My small blogpost on this<br />
<a href="http://usman-suglatwala.blogspot.com/2011/11/discarding-changes-in-linq-memory.html" onclick="javascript:pageTracker._trackPageview('/outbound/comment/http://usman-suglatwala.blogspot.com/2011/11/discarding-changes-in-linq-memory.html');" rel="nofollow">http://usman-suglatwala.blogspot.com/2011/11/discarding-changes-in-linq-memory.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Unit testing an Entity Framework DAL part 1: Just hit the database by Unit testing an Entity Framework DAL part 2: Rolling back the test database &#124; Graeme Hill's Dev Blog</title>
		<link>http://graemehill.ca/unit-testing-an-entity-framework-data-access-layer-part-1-just-hit-the-database/comment-page-1#comment-1435</link>
		<dc:creator>Unit testing an Entity Framework DAL part 2: Rolling back the test database &#124; Graeme Hill's Dev Blog</dc:creator>
		<pubDate>Fri, 28 Oct 2011 03:14:41 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=119#comment-1435</guid>
		<description>[...]      &#171; Unit testing an Entity Framework DAL part 1: Just hit the database Converting from SVN to Git [...]</description>
		<content:encoded><![CDATA[<p>[...]      &laquo; Unit testing an Entity Framework DAL part 1: Just hit the database Converting from SVN to Git [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Discard changes in LINQ to SQL DataContext by Jimbo</title>
		<link>http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/comment-page-1#comment-1433</link>
		<dc:creator>Jimbo</dc:creator>
		<pubDate>Wed, 26 Oct 2011 14:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://graemehill.ca/?p=5#comment-1433</guid>
		<description>Glad I found this, creating a new DataContext was just not an option for me - your code works great, thanks :)</description>
		<content:encoded><![CDATA[<p>Glad I found this, creating a new DataContext was just not an option for me - your code works great, thanks <img src='http://graemehill.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

