<?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 on: Linq To SQL Tutorial &#8211; Set inheritance modifiers with SQLMetal</title>
	<atom:link href="http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/</link>
	<description>Everything .NET and C#</description>
	<lastBuildDate>Wed, 01 Feb 2012 21:25:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: منابع یادگیری LINQ &#124; alisite</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-21315</link>
		<dc:creator>منابع یادگیری LINQ &#124; alisite</dc:creator>
		<pubDate>Wed, 01 Feb 2012 21:25:27 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-21315</guid>
		<description>[...] to SQL Tips 8: How to (and why) create a partial class in the designer to augment generated code   Set inheritance modifiers with SQLMetal  Linq to SQL with WCF Services  ObjectDataSource binding with paging and sorting  Using [...]</description>
		<content:encoded><![CDATA[<p>[...] to SQL Tips 8: How to (and why) create a partial class in the designer to augment generated code   Set inheritance modifiers with SQLMetal  Linq to SQL with WCF Services  ObjectDataSource binding with paging and sorting  Using [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jo Kvalvaag</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-21268</link>
		<dc:creator>Jo Kvalvaag</dc:creator>
		<pubDate>Tue, 15 Nov 2011 00:30:08 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-21268</guid>
		<description>Just love this implementation, Joe. This and the Base Repository/Business Logic wrapper articles are really golden. Thank you so much for sharing! 

I tried it out with a new project I am doing. The only thing I did not like abou it, was the messing about with the designer files in the DBML, adding the override to the ID property for each entity. Changing tool generated code is for me an absolute taboo, as you can only do that if you work alone.

What I ended up doing instead was to declare a
public abstract int GetID();
in my entitybase, and then a
public override int GetID()
{
	return this.ID;
}

in each partial class of my entities. 

Then, 

public bool IsNew {
	get { return GetID() == 0; }
}

back in the entity class should do the trick without mocking about with generated code. 

Also, the attach method in existing records does not make much sense, does it? Why attach here (at least check if the entity is already attached first?): 

public void Save(T entity)    {        
if (entity.IsNew)        {            
_context.GetTable().InsertOnSubmit(entity);        
}        
else        
{            _context.GetTable().Attach(entity, true);        
}         
_context.SubmitChanges();    
}

Thanks again for the insight!</description>
		<content:encoded><![CDATA[<p>Just love this implementation, Joe. This and the Base Repository/Business Logic wrapper articles are really golden. Thank you so much for sharing! </p>
<p>I tried it out with a new project I am doing. The only thing I did not like abou it, was the messing about with the designer files in the DBML, adding the override to the ID property for each entity. Changing tool generated code is for me an absolute taboo, as you can only do that if you work alone.</p>
<p>What I ended up doing instead was to declare a<br />
public abstract int GetID();<br />
in my entitybase, and then a<br />
public override int GetID()<br />
{<br />
	return this.ID;<br />
}</p>
<p>in each partial class of my entities. </p>
<p>Then, </p>
<p>public bool IsNew {<br />
	get { return GetID() == 0; }<br />
}</p>
<p>back in the entity class should do the trick without mocking about with generated code. </p>
<p>Also, the attach method in existing records does not make much sense, does it? Why attach here (at least check if the entity is already attached first?): </p>
<p>public void Save(T entity)    {<br />
if (entity.IsNew)        {<br />
_context.GetTable().InsertOnSubmit(entity);<br />
}<br />
else<br />
{            _context.GetTable().Attach(entity, true);<br />
}<br />
_context.SubmitChanges();<br />
}</p>
<p>Thanks again for the insight!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-21260</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 07 Nov 2011 04:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-21260</guid>
		<description>Amilkar

Take a look at this post: http://www.joe-stevens.com/2009/07/10/linq-to-sql-with-wcf-services/

The post example is silverlight, bit it explains why you get this issue and how you can resolve it.


Cheers
Joe</description>
		<content:encoded><![CDATA[<p>Amilkar</p>
<p>Take a look at this post: <a href="http://www.joe-stevens.com/2009/07/10/linq-to-sql-with-wcf-services/" rel="nofollow">http://www.joe-stevens.com/2009/07/10/linq-to-sql-with-wcf-services/</a></p>
<p>The post example is silverlight, bit it explains why you get this issue and how you can resolve it.</p>
<p>Cheers<br />
Joe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amilkar</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-21258</link>
		<dc:creator>Amilkar</dc:creator>
		<pubDate>Sat, 05 Nov 2011 05:34:48 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-21258</guid>
		<description>I does not work for me and thow an exception when updateing:

  public virtual void Save(T entity)    
        {     
            if (entity.IsNew)        
            {            
                _context.GetTable().InsertOnSubmit(entity);        
            }        
            else        
            {
//The Exection throw here...
                _context.GetTable().Attach(entity, true);        
            }         
            _context.SubmitChanges();    
        }   

This is the Exception message:

An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy.

Can some one help me with this?</description>
		<content:encoded><![CDATA[<p>I does not work for me and thow an exception when updateing:</p>
<p>  public virtual void Save(T entity)<br />
        {<br />
            if (entity.IsNew)<br />
            {<br />
                _context.GetTable().InsertOnSubmit(entity);<br />
            }<br />
            else<br />
            {<br />
//The Exection throw here&#8230;<br />
                _context.GetTable().Attach(entity, true);<br />
            }<br />
            _context.SubmitChanges();<br />
        }   </p>
<p>This is the Exception message:</p>
<p>An entity can only be attached as modified without original state if it declares a version member or does not have an update check policy.</p>
<p>Can some one help me with this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roberto T.</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-2171</link>
		<dc:creator>roberto T.</dc:creator>
		<pubDate>Mon, 12 Jul 2010 19:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-2171</guid>
		<description>Michael how were you able to turn the Entitybase to an interface when you have the IsNew method which seems to me, would have to exist outside of an interface.</description>
		<content:encoded><![CDATA[<p>Michael how were you able to turn the Entitybase to an interface when you have the IsNew method which seems to me, would have to exist outside of an interface.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-2040</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 21 Jun 2010 06:13:21 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-2040</guid>
		<description>Glad you found them helpful Michael

Joe</description>
		<content:encoded><![CDATA[<p>Glad you found them helpful Michael</p>
<p>Joe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-2022</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 17 Jun 2010 12:48:35 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-2022</guid>
		<description>In case your interested, I found another way to accomplish this without setting the inheritance modifiers via your console app (which is very cool by the way) or via the properties window.  I changed the BaseEntity to an interface instead of an abstract class.  This provided the same functionality with a little less work on my part.  Less work means less opportunity to make a mistake.

Thanks for all the articles.  They have really been a big help to me.</description>
		<content:encoded><![CDATA[<p>In case your interested, I found another way to accomplish this without setting the inheritance modifiers via your console app (which is very cool by the way) or via the properties window.  I changed the BaseEntity to an interface instead of an abstract class.  This provided the same functionality with a little less work on my part.  Less work means less opportunity to make a mistake.</p>
<p>Thanks for all the articles.  They have really been a big help to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-2005</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Tue, 15 Jun 2010 14:47:18 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-2005</guid>
		<description>Joe, I thought you might find this method for creating the base class helpful. I have not tried it, but I have seen this idea used in more then one place.  http://www.davidturvey.com/blog/index.php/tag/linq-to-sql/

Take care</description>
		<content:encoded><![CDATA[<p>Joe, I thought you might find this method for creating the base class helpful. I have not tried it, but I have seen this idea used in more then one place.  <a href="http://www.davidturvey.com/blog/index.php/tag/linq-to-sql/" rel="nofollow">http://www.davidturvey.com/blog/index.php/tag/linq-to-sql/</a></p>
<p>Take care</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-1985</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sat, 12 Jun 2010 03:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-1985</guid>
		<description>Hi Roberto

I don&#039;t seem to have a previous comment from you, what is the problem?

Joe</description>
		<content:encoded><![CDATA[<p>Hi Roberto</p>
<p>I don&#8217;t seem to have a previous comment from you, what is the problem?</p>
<p>Joe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: roberto T.</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-1967</link>
		<dc:creator>roberto T.</dc:creator>
		<pubDate>Thu, 10 Jun 2010 15:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-1967</guid>
		<description>I think the isnew is a cool feature and being able to set the dbml file to create entities which overrided properties from a base class is way cool.  I wish you would help me .... see previous post :(</description>
		<content:encoded><![CDATA[<p>I think the isnew is a cool feature and being able to set the dbml file to create entities which overrided properties from a base class is way cool.  I wish you would help me &#8230;. see previous post <img src='http://www.joe-stevens.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-1483</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Wed, 14 Apr 2010 04:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-1483</guid>
		<description>Hi Michael

The console application it just to easily recreate the model after making changes to the database.

If you don&#039;t want to use SQLMetal you can set inheritance modifiers from the properties window for the DBML file.

Cheers</description>
		<content:encoded><![CDATA[<p>Hi Michael</p>
<p>The console application it just to easily recreate the model after making changes to the database.</p>
<p>If you don&#8217;t want to use SQLMetal you can set inheritance modifiers from the properties window for the DBML file.</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.joe-stevens.com/2009/07/01/linq-to-sql-set-inheritance-modifiers-with-sqlmetal/comment-page-1/#comment-1401</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sun, 04 Apr 2010 22:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://joestevens.wordpress.com/?p=116#comment-1401</guid>
		<description>This post as well as most of the others have been extremely helpful to me.  You have really been a big help. I was wondering however if there was a way to accomplish the EntityBase class without modifying the dbml file with your console application. My boss is having a problem with this.

Thanks so much.</description>
		<content:encoded><![CDATA[<p>This post as well as most of the others have been extremely helpful to me.  You have really been a big help. I was wondering however if there was a way to accomplish the EntityBase class without modifying the dbml file with your console application. My boss is having a problem with this.</p>
<p>Thanks so much.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

