tags:

views:

52

answers:

2

Hi,

I am having a problem with saving of data because of an incorrectly generated parameter name.

The table has a field "E-mail", and when the class wrapper is generated, the InsertCmd uses "@E-mail" as one of the parameters. In SQL Server, this is illegal and generated an exception.

I have hunted all over SubSonic for a way to modify the parameter name to simply "@Email" but the ParameterName property is read only.

I am using SubSonic 2.2 and don't have the source for it to make an internal modification.

Any ideas?

TIA

+1  A: 

You can modify the templates if you can't change the column name. See this blog post for details of how:

http://johnnycoder.com/blog/2008/06/09/custom-templates-with-subsonic/

Adam
+2  A: 

I got a mate of mine that uses SVN to pull the source code, and as expected, found a bug in the SS source.

When the column name is set in the class wrapper, the setter for the ColumnName property sets the ParamaterName property for you correctly using "parameterName = Utility.PrefixParameter(Utility.StripNonAlphaNumeric(columnName), Table.Provider);". This removes any illegal characters like the hyphen in my E-mail column.

BUT... The property ParameterName is NOT used when the SQL commands are created. Here is the code in SQLDataProvider.GetInsertSQL, line 1462.

pars.Append(Utility.PrefixParameter( colName, this));

I changed this to

pars.Append(col.ParameterName);

and the problem is now sorted.

Thanks to you that came up with possible solutions.