<?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 : VARCHAR treated as NVARCHAR</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : VARCHAR treated as NVARCHAR</description>
  <pubDate>Tue, 12 May 2026 18:03:25 -700</pubDate>
  <lastBuildDate>Mon, 11 May 2015 15:13:46 -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=3503</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>VARCHAR treated as NVARCHAR : Here&amp;#039;s a more recent example...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=17554#17554</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 11-May-2015 at 3:13pm<br /><br />Here's a more recent example of a custom provider helper which is able to detect column information.  The example below detects Xml data types and excludes columns of this type from parameter mapping for insert/update/delete statements.<br /><br />public class CustomProviderHelper : IdeaBlade.Rdb.SqlServerProviderHelper {<br /><br />&nbsp;&nbsp;&nbsp;// Reset ALL strings to Ansi strings for select/insert/update/delete parms<br />&nbsp;&nbsp;&nbsp;public override System.Data.DbType MapDbParameterType(System.Data.DbType pDbType) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return pDbType == System.Data.DbType.String ? System.Data.DbType.AnsiString : pDbType;<br />&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;// This is called by the RdbAdapterProvider when building insert/update/delete statements.<br />&nbsp;&nbsp;&nbsp;// We have enough column information here to detect XML types, and reset the parameter.DbType.<br />&nbsp;&nbsp;&nbsp;public override void QualifyParameter(System.Data.IDbDataParameter pParameter, System.Data.DataRow pSchemaRow) {<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Do base logic<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;base.QualifyParameter(pParameter, pSchemaRow);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// This was typed as an ansi string by MapDbParameter, reset to correct Xml datatype.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((Type)pSchemaRow&#091;"ProviderSpecificDataType"&#093; == typeof(System.Data.SqlTypes.SqlXml)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pParameter.DbType = System.Data.DbType.Xml;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// There may be other useful schema info here too - like pSchemaRow&#091;"DataTypeName"&#093;<br />&nbsp;&nbsp;&nbsp;}<br />}<br />]]>
   </description>
   <pubDate>Mon, 11 May 2015 15:13:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=17554#17554</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Posted on behalf of user toddgleason...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=17553#17553</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=3" rel="nofollow">JoshO</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 07-Jan-2015 at 8:21am<br /><br /><div>Posted on behalf of user <a href="http://www.ideablade.com/forum/search_results_posts.asp?SearchID=20150107112013&amp;KW=" target="_blank">toddgleason</a> :</div><div><br></div><div>At first we tried the solution mentioned, involving aSqlServerProviderHelper (not sure if I got that class name right).  This actually worked fine for most tables,but for any tables with XML columns, those would no longer come back correctlyfrom the DB. They needed to be encoded in NVARCHAR and no longer were.</div><div>&nbsp;</div><div><span style="line-height: 1.4;">I then began investigating whether an IAdapterProvidersolution was the way to go.&nbsp; Afterfiddling with this, and tracing through DevForce code in Reflector, I realizedthat this was only mostly dealing with the object schema and not reallyinvolved with the actual parameters involved in a fetch operation.</span></div><div>&nbsp;</div><div><span style="line-height: 1.4;">The solution I ended up with seems to be good. It hingedon the fact that we subclassed the PersistenceManager with a company-specificversion long ago, and have faithfully used our own class.&nbsp; This is critical because we created"new" versions of the GetEntity()/GetEntities()-style methods. (Thesereally should have been virtual to begin with; then our coverage would have beeneven more complete, but we think it's good enough for this case.)</span></div><div>&nbsp;</div><div><span style="line-height: 1.4;">Within our GetEntity()/GetEntities() methods, we"promote" the IEntityQuery into a company-specific class derived fromRdbQuery. (We do this for EntityQuery and RdbQuery but not pass-thruqueries.)&nbsp; And in our RdbQuery subclass,we override the Fetch() method of RdbQuery to do everything the base classdoes, but also tweak the query parameter types:</span></div><div>&nbsp;<span style="line-height: 1.4;">&nbsp;</span></div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;summary&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Thismethod is not intended to be called directly from your code.</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;/summary&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;param name="pDataSet"&gt;The dataset holding fetcheddata&lt;/param&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;param name="pDataSourceKey"&gt;The data source key containingconnection information for the datasource.&lt;/param&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;remarks&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// Thismethod executes on the server side of the Persistence divide to</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///retrieve data from the backend datasource.</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ///&lt;/remarks&gt;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; publicoverride void Fetch(DataSet pDataSet, IDataSourceKey pDataSourceKey)</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AdoHelper adoHelper = ((RdbKey)pDataSourceKey).AdoHelper;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RdbQuerySqlFormatter formatter = new RdbQuerySqlFormatter(adoHelper,(base.QueryStrategy == null) ? null : base.QueryStrategy.TransactionSettings);</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CanonicalSqlQuery pQuery = formatter.BuildCanonicalQuery(this);</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ParameterizedSql pParamSql = formatter.BuildSqlSelect(pQuery);</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // SQLhas an issue with sending varchar columns as nvarchar; see</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <a href="http://lostechies.com/jimmybogard/2012/07/18/troubleshooting-sql-index-per&#102;ormance-&#111;n-varchar-columns/" target="_blank">http://lostechies.com/jimmybogard/2012/07/18/troubleshooting-sql-index-performance-on-varchar-columns/</a></div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Aglobal type mapping change can be done,</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // butit fails because XML columns need to be sent in Unicode instead of using the DBcollation, and conversion to ANSI breaks compatibility with such columns.</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Sothe solution is to instead, at fetch time, replace parameters marked asNVarChar with VarChar</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // It'sunlikely we actually query by those XML parameters so this should be relativelysafe.&nbsp; This only affects</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // theparameters sent out in the query, not the return type mappings.</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Oneother thing we do is that in our own PersistenceManager subclass's GetEntity()/GetEntities()calls, we "promote" all</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //EntityQuery and RdbQuery objects to our derived objects, to guarantee invokingthis class.</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(var param in pParamSql.Parameters)</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(param.DbType == DbType.String)</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param.DbType = DbType.AnsiString;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using(formatter)</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;formatter.Fetch(base.EntityType, pDataSet, pParamSql,this.CommandTimeout);</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.FetchSpans(pQuery, pDataSet, adoHelper, formatter);</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(base.ContainsSubquery &amp;&amp; !this.SuppressQueryInversion)</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.FetchInverted(pDataSet, formatter, this);</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;</div><div>&nbsp;</div><div>&nbsp;</div><div>You may also note that in here we could put extraintelligence in if we needed to apply this logic conditionally, such as byparameter name, or we could add to the query class to control the behavior.<span style="line-height: 1.4;">&nbsp;</span></div><div>&nbsp;</div><div>The resulting solution has zero effect on the data typetransfer in either direction; it only affects the query parameters, which isexactly what we want.</div>]]>
   </description>
   <pubDate>Wed, 07 Jan 2015 08:21:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=17553#17553</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Just to let you know it seems...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16684#16684</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1737" rel="nofollow">ctoth</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 01-Aug-2013 at 11:32am<br /><br />Just to let you know it seems that&nbsp;in our current configuration we specify that assembly in the global probe assembly list (not for the RdbKey probe assembly list), and it seems to work that way too: when I profile the SQL queries I see varchar parameters passed. So we don't have an nvarchar/varchar conversion problem I think.]]>
   </description>
   <pubDate>Thu, 01 Aug 2013 11:32:46 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16684#16684</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Oh! I missed that, thanks for...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16672#16672</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1737" rel="nofollow">ctoth</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 30-Jul-2013 at 11:29am<br /><br />Oh! I missed that, thanks for warning me! That's important!]]>
   </description>
   <pubDate>Tue, 30 Jul 2013 11:29:31 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16672#16672</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Specifically for the RdbKey. DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16671#16671</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 30-Jul-2013 at 11:23am<br /><br />Specifically for the RdbKey.&nbsp; DevForce will look at the "global" probeAssemblyNames for some things, and the key-specified ones for others.&nbsp; Here it will look for the key's probe assemblies.]]>
   </description>
   <pubDate>Tue, 30 Jul 2013 11:23:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16671#16671</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Thanks kimj, that information...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16670#16670</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1737" rel="nofollow">ctoth</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 30-Jul-2013 at 11:19am<br /><br />Thanks kimj, that information is enough. So the assembly has to be in the list of probe assemblies in IdeaBlade.config.<br>]]>
   </description>
   <pubDate>Tue, 30 Jul 2013 11:19:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16670#16670</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : The AdoProviderHelper is unfortunately...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16669#16669</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 30-Jul-2013 at 11:14am<br /><br />The AdoProviderHelper is unfortunately not documented, other than class information in the help reference, and we don't have any samples showing the how/when/why of using it.<DIV sab="1263">&nbsp;</DIV><DIV sab="1264">The code snippet in the second post in this thread is actually complete - you can copy&nbsp;the SampleProviderHelper class into a file, add the file to a project, and be sure the project's assembly is included in the probe assemblies for your RdbKey.&nbsp; DevForce will use your implementation if its found.&nbsp; There are a number of other members which can be overridden too.</DIV><DIV sab="1264">&nbsp;</DIV><DIV sab="1264">If you're running into problems please provide more specifics on what you need to do or what's not working.</DIV>]]>
   </description>
   <pubDate>Tue, 30 Jul 2013 11:14:47 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16669#16669</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Do you have some more complete...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16668#16668</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1737" rel="nofollow">ctoth</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 30-Jul-2013 at 10:44am<br /><br />Do you have some more complete example about extending<span style="color:#2b91af;"> OleDbProviderHelper</span>? What else need to be done besides extending it?]]>
   </description>
   <pubDate>Tue, 30 Jul 2013 10:44:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=16668#16668</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR :   This is going to be tough....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13882#13882</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 20-Jun-2012 at 7:38pm<br /><br />This is going to be tough.&nbsp; Unfortunately, there's no useful information, such as table or column name, coming into the provider helper that you can capture and use.&nbsp; Sorry, option 3 may be the only one that will work.]]>
   </description>
   <pubDate>Wed, 20 Jun 2012 19:38:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13882#13882</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Kim,Thanks. That seems like a...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13881#13881</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=512" rel="nofollow">aschaff</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 20-Jun-2012 at 6:46pm<br /><br />Kim,<br>Thanks. That seems like a start. However, our database is a mix of both varchar and nvarchar, so neither choice (ansi or unicode) is correct all of the time. Ideally, I'd like to base it on the dbtype of the source sql column from which the entity column originated. If that is not possible, next best would be to test the column name, since our naming conventions provide a fairly reliable indicator. But I do not see any parameters to that override method that would help me to access the EntityColumn at issue. Any thoughts?<br><br>-Adam<br><br>p.s.<br>I guess my third choice, of last resort, would be to default to unicode (since that's what we have today) and test some kind of global that we can set and clear before and after the query is executed. Not pretty, but it's a lifeline I guess. <br>]]>
   </description>
   <pubDate>Wed, 20 Jun 2012 18:46:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13881#13881</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR :   Hi Adam,In ADO.NET the &amp;#034;String&amp;#034;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13879#13879</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 20-Jun-2012 at 3:22pm<br /><br />Hi Adam,<div>&nbsp;</div><div>In ADO.NET the "String" CLR type is considered a Unicode string, which is then interpreted as an nvarchar database type.  So DevForce is just allowing this default to occur.&nbsp;&nbsp; You can work around the problem with a custom "AdoProviderHelper" which will allow you to take control of the database type.<br><br>If you're&nbsp;using the SQLOLEDB provider you can implement the helper like this:<br><font size="2"><font size="2"></font></font></div><div><font face="C&#111;nsolas"><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">public</font></font></font><font size="2"><font size="2"> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">class</font></font></font><font size="2"><font size="2"> </font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">SampleProviderHelper</font></font></font><font size="2"><font size="2"> : </font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">OleDbProviderHelper</font></font></font></font><font face="C&#111;nsolas"><font size="2"><font size="2"> {<br></font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">  &nbsp;&nbsp; public</font></font></font><font size="2"><font size="2"> </font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">override</font></font></font><font size="2"><font size="2"> </font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">DbType</font></font></font><font size="2"><font size="2"> MapDbParameterType(</font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">DbType</font></font></font></font><font face="C&#111;nsolas"><font size="2"><font size="2"> pDbType) {<br></font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font color="#0000ff" size="2">     &nbsp;&nbsp;&nbsp;&nbsp; return</font></font></font><font size="2"><font size="2"> pDbType == </font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">DbType</font></font></font><font size="2"><font size="2">.String ? </font></font><font color="#2b91af" size="2"><font color="#2b91af" size="2"><font color="#2b91af" size="2">DbType</font></font></font></font><font size="2" face="C&#111;nsolas">.AnsiString : pDbType;<br> &nbsp;&nbsp; }<br>}<br><br></font><font size="2" face="Arial">If you're&nbsp;using the SQLClient provider you'd instead subclass&nbsp;the SqlServerProviderHelper class:<br></font><font color="#0000ff"><font color="#0000ff"><font color="#0000ff"><br><font size="2" face="C&#111;nsolas">   public</font></font></font></font><font face="C&#111;nsolas"><font size="2"> <font color="#0000ff"><font color="#0000ff"><font color="#0000ff">class</font></font></font> <font color="#2b91af"><font color="#2b91af"><font color="#2b91af">SampleProviderHelper</font></font></font> : <font color="#2b91af"><font color="#2b91af"><font color="#2b91af">SqlServerProviderHelper</font></font></font></font></font><font face="C&#111;nsolas"><font size="2"> {.. }<br><br></font><font size="2" face="Arial">Both OleDbProviderHelper and SqlServerProviderHelper are defined in IdeaBlade.Rdb.<br><br></font></font><font size="2" face="Arial">For DevForce to find your custom implementation be sure that the assembly it's in is defined as a probe assembly for the RdbKey.<br><br></div></font>]]>
   </description>
   <pubDate>Wed, 20 Jun 2012 15:22:59 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13879#13879</guid>
  </item> 
  <item>
   <title>VARCHAR treated as NVARCHAR : Hello.For a while now we have...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13878#13878</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=512" rel="nofollow">aschaff</a><br /><strong>Subject:</strong> 3503<br /><strong>Posted:</strong> 20-Jun-2012 at 1:28pm<br /><br />Hello.<br>For a while now we have been aware that DevForce uses parameterized queries and treats the string parameters as unicode, even if the entity was built from a table with varchar columns instead of nvarchar. In some cases this is causing us performance problems. In particular, when the column involved is (a) varchar, and (b) indexed but NOT part of the primary key of the table, then the index is NOT used resulting in terrible performance if the table has a lot of rows. <br><br>Here is an example of one of these queries that specifies nvarchar for the OrderNum and places an "N" prefix in front of the value ('1121') even though this is a varchar field:<br><br>exec sp_executesql N'select * from "dbo"."fOrderStep" where (("dbo"."fOrderStep"."OrderStepSequenceNum"=@P1 and "dbo"."fOrderStep"."OrderNum"=@P2))',N'@P1 float,@P2 nvarchar(4)',10,N'1121'<br><br>I need a way to prevent this treatment of varchar as nvarchar. Can anyone help me out?<br>-Adam<br>]]>
   </description>
   <pubDate>Wed, 20 Jun 2012 13:28:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3503&amp;PID=13878#13878</guid>
  </item> 
 </channel>
</rss>