<?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 : String field MaxLength</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : String field MaxLength</description>
  <pubDate>Sat, 16 May 2026 14:06:03 -700</pubDate>
  <lastBuildDate>Tue, 14 Sep 2010 12:00:43 -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=2152</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>String field MaxLength : That will work. Thank you!  </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8494#8494</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=704" rel="nofollow">mikewishart</a><br /><strong>Subject:</strong> 2152<br /><strong>Posted:</strong> 14-Sep-2010 at 12:00pm<br /><br />That will work.&nbsp; Thank you!]]>
   </description>
   <pubDate>Tue, 14 Sep 2010 12:00:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8494#8494</guid>
  </item> 
  <item>
   <title>String field MaxLength : Hi Mike;I&amp;#039;m assuming that...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8491#8491</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2152<br /><strong>Posted:</strong> 14-Sep-2010 at 11:17am<br /><br />Hi Mike;<div><br></div><div>I'm assuming that you want to get the MaxValue of the StringLengthVerifierAttribute. If so, we can create a function that can be passed any DevForce entity and its property, and using its type and property name, we can using Reflections to get its MaxValue of the StringLengthVerifierAttribute. Please see code samples below.</div><div><br></div><div><div>public void GetMaxStringLengthSample() {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var maxStringLength = GetMaxStringLengthAttribute(typeof(Customer), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Customer.PropertyMetadata.CompanyName.Name);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; Assert.IsTrue(maxStringLength == 40, "This should not fail");</div><div>}</div><div><br></div><div>public int GetMaxStringLengthAttribute(Type entityType, String propertyName) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var propertyInfo = entityType.GetProperty(propertyName);</div><div>&nbsp;&nbsp; &nbsp; &nbsp;var attributes = (StringLengthVerifierAttribute)propertyInfo</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;.GetCustomAttributes(typeof(StringLengthVerifierAttribute), false).First();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;return attributes.MaxValue;</div><div>}</div></div>]]>
   </description>
   <pubDate>Tue, 14 Sep 2010 11:17:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8491#8491</guid>
  </item> 
  <item>
   <title>String field MaxLength : I&amp;#039;d like to make it a little...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8477#8477</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=704" rel="nofollow">mikewishart</a><br /><strong>Subject:</strong> 2152<br /><strong>Posted:</strong> 13-Sep-2010 at 2:29pm<br /><br />I'd like to make it a little easier to determine the maximum length of a string field rather than hardcoding it in a few places.&nbsp; Is there any DevForce equivalent to the solution presented here?<br><br><a href="http://stackoverflow.com/questi&#111;ns/748939/field-max-length-in-entity-framwork" target="_blank">http://stackoverflow.com/questions/748939/field-max-length-in-entity-framwork</a><br><br><br>]]>
   </description>
   <pubDate>Mon, 13 Sep 2010 14:29:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2152&amp;PID=8477#8477</guid>
  </item> 
 </channel>
</rss>