<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Validation Upon Save</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Validation Upon Save</description>
  <pubDate>Sun, 12 Apr 2026 17:10:23 -700</pubDate>
  <lastBuildDate>Wed, 09 Mar 2011 05:40:57 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2548</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Validation Upon Save :   Much thanks, Silvio. </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10138#10138</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1019" rel="nofollow">jipock</a><br /><strong>Subject:</strong> 2548<br /><strong>Posted:</strong> 09-Mar-2011 at 5:40am<br /><br />Much thanks,&nbsp; Silvio. ]]>
   </description>
   <pubDate>Wed, 09 Mar 2011 05:40:57 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10138#10138</guid>
  </item> 
  <item>
   <title>Validation Upon Save : Hi jipock,   Assuming that the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10135#10135</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2548<br /><strong>Posted:</strong> 08-Mar-2011 at 4:47pm<br /><br /><DIV>Hi jipock, </DIV><DIV>&nbsp;</DIV><DIV>Assuming that the entity type you are looking for is Employee, the Property is LastName,&nbsp;and you are validating only new entities:</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>protected</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>override</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>bool</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> ValidateSave() {</DIV><DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> em = EntityManager;</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> foundEntities = em.FindEntities(<FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>typeof</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>), </FONT></FONT></FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>EntityState</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Added);</FONT></FONT></DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; foreach</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> entity </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>in</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> foundEntities.Cast&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Object</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;().ToList()) {</DIV><DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; if</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> (entity.LastName == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#0000ff>null</FONT></FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>) {</DIV><DIV>&nbsp;&nbsp;&nbsp; em.RemoveEntity(entity);</DIV><DIV>&nbsp; }</DIV><DIV></FONT></FONT><FONT size=2><FONT face=C&#111;nsolas><FONT color=#0000ff>&nbsp;&nbsp;</FONT><FONT color=#0000ff>return</FONT> <FONT color=#0000ff><FONT color=#0000ff><FONT color=#0000ff>base</FONT></FONT></FONT>.ValidateSave();</FONT></FONT><FONT color=#008000><FONT color=#008000><FONT color=#008000></DIV></DIV><DIV><DIV></FONT></FONT></FONT><FONT size=2><FONT size=2><FONT face=C&#111;nsolas>}</FONT></FONT></FONT></DIV></DIV></DIV><DIV>&nbsp;</DIV><DIV>Note that,&nbsp;back in the client, while the successfully saved entities were updated to EntityState.Unchanged,&nbsp;the "unsaved" entities still have EntityState.Added.</DIV><DIV>&nbsp;</DIV><DIV>Silvio.</DIV><span style="font-size:10px"><br /><br />Edited by sbelini - 08-Mar-2011 at 5:21pm</span>]]>
   </description>
   <pubDate>Tue, 08 Mar 2011 16:47:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10135#10135</guid>
  </item> 
  <item>
   <title>Validation Upon Save : Good Afternoon,   I&amp;#039;m attempting...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10132#10132</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1019" rel="nofollow">jipock</a><br /><strong>Subject:</strong> 2548<br /><strong>Posted:</strong> 08-Mar-2011 at 10:20am<br /><br />Good Afternoon, <DIV>&nbsp;</DIV><DIV>I'm attempting now to validate an entity upon save that is Property1 on a specific&nbsp;entity type&nbsp;is null then stop the save and throw an exception. </DIV><DIV>&nbsp;</DIV><DIV>I'm not finding a good way to do this... I thought to look into the EntityServerSaveInterceptor, but ValidateSave() doesn't take parameters, nor do I find a way of grabbing the entities being saved (and manually loop through all of them). The entity itself does have PropertyInterceptors for individual properties (before Set, After Set, etc.), but I don't want to check it until Save time. </DIV><DIV>&nbsp;</DIV><DIV>Any suggestions on this?</DIV>]]>
   </description>
   <pubDate>Tue, 08 Mar 2011 10:20:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2548&amp;PID=10132#10132</guid>
  </item> 
 </channel>
</rss>