<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Generation Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/category/development/code-generation/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/category/development/code-generation/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 10 Jan 2019 12:46:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>nettiers &#8211; GetBy Index problem with StoredProcedure long name</title>
		<link>https://blogit.create.pt/ricardocosta/2016/05/31/nettiers-getby-index-problem-with-storedprocedure-long-name/</link>
					<comments>https://blogit.create.pt/ricardocosta/2016/05/31/nettiers-getby-index-problem-with-storedprocedure-long-name/#respond</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Tue, 31 May 2016 15:24:25 +0000</pubDate>
				<category><![CDATA[CodeSmith]]></category>
		<category><![CDATA[nettiers]]></category>
		<category><![CDATA[Code Generation]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=1152</guid>

					<description><![CDATA[<p>Today I&#8217;ve discovered a problem with CodeSmith nettiers templates because it was possible to generate two SPs with the same name, for different entities. This happens when there are two indexes for two different tables that have the same column names and the column names reach the maximum lenght (128 for SQL). In this case the generated [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2016/05/31/nettiers-getby-index-problem-with-storedprocedure-long-name/">nettiers &#8211; GetBy Index problem with StoredProcedure long name</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today I&#8217;ve discovered a problem with <a href="http://www.codesmithtools.com">CodeSmith </a><a href="https://github.com/netTiers/netTiers">nettiers </a>templates because it was possible to generate two SPs with the same name, for different entities.</p>
<p>This happens when there are two indexes for two different tables that have the same column names and the column names reach the maximum lenght (128 for SQL). In this case the generated SP name doesn&#8217;t contain the table name as a prefix.</p>
<p>Here is the original nettiers code for the GetProcNameForGetByIX method in CommonSqlCode.cs:</p>
<pre class="brush: csharp; title: ; notranslate">
// get the key names one at a time until we run out of space
stringbuilder names = new stringbuilder(maxlen);
 
string keyname;
for(int x = 0; x &lt; keys.length; x++)
{
  keyname = getpropertyname(keys&#x5B;x]);
  if (names.length + keyname.length &lt;= maxlen)
    names.append(keyname);
  else
    break;
}
return names.tostring();
</pre>
<p>I&#8217;ve upgraded the method to receive the index name and the new code is:</p>
<pre class="brush: csharp; title: ; notranslate">
if (string.IsNullOrEmpty(indexName))
 {
   throw new Exception(&quot;Need index name&quot;);
 }
 
 string name = string.Concat(prefix, indexName);
 
 if (name.Length &gt; maxLen)
 {
   throw new Exception(&quot;SP name continues to be greater than maxlen&quot;);
 }
 
 return name;
</pre>
<p>Then I needed to pass the index name on all the places that this method was call. Just use find in files and search for that method.</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2016/05/31/nettiers-getby-index-problem-with-storedprocedure-long-name/">nettiers &#8211; GetBy Index problem with StoredProcedure long name</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2016/05/31/nettiers-getby-index-problem-with-storedprocedure-long-name/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
