subsonic / SubSonic-3.0-Templates

T4 Template Project for the peeps
http://subsonic.github.io/
105 stars 46 forks source link

Removing _ from Column names causes strange behaviour in MYSQL and MSSQL #45

Open b2802 opened 14 years ago

b2802 commented 14 years ago

For testing purpose I renamed CustomerID in Northwind DB to CustomerID and used the checked in version of Settings.ttinclude with function CleanUpColumnName. This function has line res=res.Replace("","") before returning. In ActiveRecords Customer_ID is "transformed" to CustomerId. now using var cust = SouthWind.Customer.Find(x => x.CustomerId.StartsWith("A")); in code results in Exception: Unknown Column Name 'CustomerId' [SqlException (0x80131904): Ungültiger Spaltenname 'CustomerId'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2394 System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33 System.Data.SqlClient.SqlDataReader.get_MetaData() +83 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) +10 SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) in E:\Develop_tools\SubSonic\Subsonic3\SubSonic-3.0\SubSonic.Core\DataProviders\DbDataProvider.cs:137 SubSonic.Linq.Structure.DbQueryProvider.Execute(QueryCommand1 query, Object[] paramValues) in E:\Develop_tools\SubSonic\Subsonic3\SubSonic-3.0\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:280 lambda_method(ExecutionScope ) +605 SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression) in E:\Develop_tools\SubSonic\Subsonic3\SubSonic-3.0\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:131 SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) in E:\Develop_tools\SubSonic\Subsonic3\SubSonic-3.0\SubSonic.Core\Linq\Structure\QueryProvider.cs:50 SubSonic.Linq.Structure.Query1.GetEnumerator() in E:\Develop_tools\SubSonic\Subsonic3\SubSonic-3.0\SubSonic.Core\Linq\Structure\Query.cs:85 System.Collections.Generic.List1..ctor(IEnumerable1 collection) +7667878 System.Linq.Enumerable.ToList(IEnumerable1 source) +61 SouthWind.Customer.Find(Expression1 expression) in E:\SourceWeb\SubSonic3\DALTEST\DAL_MS\ActiveRecord.cs:694 DALTEST._Default.Page_Load(Object sender, EventArgs e) in E:\SourceWeb\SubSonic3\DALTEST\Default.aspx.cs:47 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

using this code on the other hand : var db = new SouthWind.NorthwindDB(); var cust2=db.Select.From<SouthWind.Customer().ExecuteTypedList(); doesn't cause an exception and returns 91 values but all elements inside list have CustomerId=null.

Commenting out line res = res.Replace("",""); in settings.ttinclude fixes this problem Has anyone an explanation why changing UpperCase to LowerCase has no influence but any other changing EG. removing or replacing "ID" with "TEST" causes problems.