Reputation: 71161
When I examine the .Columns property of one of my business entities I had missing values for Table and PropertyName. I get the right count of records back from things like Take(5) but all 5 objects will be full of empty strings and 0 values.
Just tried it with another SQL connection and same thing? Where should I start troubleshooting this?
ADDITIONAL INFO and CODE:
// Replacing the CleanUp function seems to be cause
// What am I doing here that is not allowed?
// I'm dealing with Table names like USER_DETAILS and would prefer UserDetail
// rename standard CleanUp to CleanUp2 then paste this into Settings.ttinclude
string CleanUp(string tableName)
{
string res = tableName;
//capitalization
char[] ca = res.ToLower().ToCharArray();
for (int i = 0; i < ca.Length; i++) {
if ((i == 0) || (ca[i - 1] == '_')) {
ca[i] = char.ToUpper(ca[i]);
}
}
res = new string(ca);
//strip underlines
res = res.Replace("_","");
//strip blanks
res = res.Replace(" ","");
return res;
}
SOLVED (sort of): Looks like it is the removal of the underlines that causes everything to go south. Rob, any chance this could work in a later version? I'd be glad to help if you could point me in the right direction in the source.
Upvotes: 1
Views: 616
Reputation:
After running through the code base I think I've identified an easier solution (IMHO).
The IColumn interface has a 'PropertyName' property defined which I believe is designed to indicate the name of the property representing this column on the table class (akin to the 'ClassName' property on ITable). In the Structs.tt template this is not set so I have set it (circa line 39) to the value of the columns CleanName property.
This then allows the GetColumnByPropertyName method in DatabaseTable.cs (circa line 110) to use the PropertyName as opposed to using the Name.
I've added the Name property to the IColumn interface as it seemed to be an oversight, which then means that the Load extension method (Database.cs circa line 143) can be amended to access the Columns property of the passed in object (if it is a derivative of IActiveRecord) and use that to map the 'Name' to the 'PropertyName'.
If I can get the time to figure our GitHub I'll submit the changes.
Cheers
Gary
Upvotes: 0
Reputation: 1677
I've just applied your CleanUp function within my SubSonic3 Templates. It works just fine. But before do that, I made some patches within Subsonic Core to communicate between Subsonic objects and table column.
You can look details what I'm doin in here.
Upvotes: 0
Reputation: 4970
Just to note, I think this is the same as issue #107 that I ran into last week. http://github.com/subsonic/SubSonic-3.0/issues#issue/107
Upvotes: 2
Reputation:
If you can post your CREATE sql for one of your tables - that would be a way to get started. Also - make sure you have primary keys, etc.
Upvotes: 2