<?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 : FixedLength fields</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : FixedLength fields</description>
  <pubDate>Mon, 13 Apr 2026 20:45:32 -700</pubDate>
  <lastBuildDate>Mon, 27 Dec 2010 19:28:45 -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=2403</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>FixedLength fields : I see.Another suggestion is to...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9488#9488</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> 2403<br /><strong>Posted:</strong> 27-Dec-2010 at 7:28pm<br /><br />I see.&nbsp;<div><br></div><div>Another suggestion is to do the trimming on a varchar on the SQL database. You can use SQL_Variant_PROPERTY function to determine the field type and LTrim or RTrim function to do the trimming.</div><div><br></div>]]>
   </description>
   <pubDate>Mon, 27 Dec 2010 19:28:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9488#9488</guid>
  </item> 
  <item>
   <title>FixedLength fields : Hi Dennis,Thanks for the link....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9484#9484</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> 2403<br /><strong>Posted:</strong> 27-Dec-2010 at 5:02pm<br /><br />Hi Dennis,<br><br>Thanks for the link.&nbsp; I'll look at it.&nbsp; Trying to write a save event handler on the entitymanager which trims leading/trailing characters of all the varchar() fields and Nulls those that support it.&nbsp; Just a generic safety.&nbsp; The problem is that some of the fields are char() and shouldn't be trimmed.<br><br>for example... right now I have any string&#091;6&#093; hardcoded to not be trimmed...&nbsp; Not elegant but functional for our application.<br><br>&nbsp;&nbsp;&nbsp; private static void TrimStringProperties(IEnumerable&lt;object&gt; entities)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Entity entity in entities)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var properties = entity.GetType().GetProperties().Where(p =&gt; p.PropertyType == typeof(string));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (var property in properties)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var attributeNames = property.GetCustomAttributes(false).Select(a =&gt; a.ToString()).ToList();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!attributeNames.Any(a =&gt; a.Contains("DataMemberAttribute")))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var isNullable = ((IBaseEntity)entity).IsNullable(property.Name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var maxLength = ((IBaseEntity)entity).MaxStringLength(property.Name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (maxLength == 6) continue; // fixed length char(6) properties<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var value = (string)property.GetValue(entity, null);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value == null) continue;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = value.Trim();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isNullable &amp;&amp; string.IsNullOrEmpty(value))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = null;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; property.SetValue(entity, value, null);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>]]>
   </description>
   <pubDate>Mon, 27 Dec 2010 17:02:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9484#9484</guid>
  </item> 
  <item>
   <title>FixedLength fields : mikewishart;Unfortunately there...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9483#9483</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> 2403<br /><strong>Posted:</strong> 27-Dec-2010 at 4:52pm<br /><br /><div style=": rgb255, 255, 255; margin-left: 1px; margin-top: 1px; margin-right: 1px; margin-bottom: 1px; font-family: Verdana, Arial, Helvetica, sans-serif; color: rgb0, 0, 0; font-weight: normal; font-size: 12px; line-height: 1.4; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; -: n&#111;ne; ">mikewishart;<div><br></div><div>Unfortunately there is no easy way to do that. What are you trying to achieve?</div><div><br></div><div>Here are some suggestions:</div><div><br></div><div>1. Read the CSDL content from the edmx.&nbsp;<a href="http://blogs.msdn.com/b/ad&#111;net/archive/2008/01/24/how-to-extract-csdl-from-edmx.aspx" target="_blank">http://blogs.msdn.com/b/adonet/archive/2008/01/24/how-to-extract-csdl-from-edmx.aspx</a></div><div><br></div><div>or</div><div><br></div><div>2. Write your own custom T4 template for code generation.</div></div>]]>
   </description>
   <pubDate>Mon, 27 Dec 2010 16:52:54 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9483#9483</guid>
  </item> 
  <item>
   <title>FixedLength fields : Is there a way to determine if...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9482#9482</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> 2403<br /><strong>Posted:</strong> 27-Dec-2010 at 12:14pm<br /><br />Is there a way to determine if a property has the FixedLength=True set at run time?<br><br>&lt;Property Name="StatusCode" Type="String" Nullable="false" MaxLength="6" Unicode="false" FixedLength="true" /&gt;<br><br>]]>
   </description>
   <pubDate>Mon, 27 Dec 2010 12:14:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2403&amp;PID=9482#9482</guid>
  </item> 
 </channel>
</rss>