You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue where a column in my database was the same name as the table itself. Subsonic correctly generated a field for it (with 'X' appended) but it wouldn't save to the datastore, and it wouldn't be populated when I fetched data from the store.
I hacked a fix in, but it's almost Christmas and I don't want to go through the official patching whatnot, so here it is (both fixes in Subsonic.Core):
in Load in Database.cs (beneath line 159), add an additional check to find a property which, without the appended X, matches the property we're trying to assign to:
//if we didn't find the property, maybe we'll find it without the last character, e.g. 'X'
if (currentProp == null)
{
currentProp = cachedProps.SingleOrDefault(x => x.Name.Substring(0, x.Name.Length - 1).Equals(pName, StringComparison.InvariantCultureIgnoreCase));
}
And, in DatabaseTable.cs around line 142, the "GetColumnByPropertyName" method, I added a similar check to have the right column be found:
I ran into an issue where a column in my database was the same name as the table itself. Subsonic correctly generated a field for it (with 'X' appended) but it wouldn't save to the datastore, and it wouldn't be populated when I fetched data from the store.
I hacked a fix in, but it's almost Christmas and I don't want to go through the official patching whatnot, so here it is (both fixes in Subsonic.Core):
in Load in Database.cs (beneath line 159), add an additional check to find a property which, without the appended X, matches the property we're trying to assign to:
//if we didn't find the property, maybe we'll find it without the last character, e.g. 'X'
if (currentProp == null)
{
currentProp = cachedProps.SingleOrDefault(x => x.Name.Substring(0, x.Name.Length - 1).Equals(pName, StringComparison.InvariantCultureIgnoreCase));
}
And, in DatabaseTable.cs around line 142, the "GetColumnByPropertyName" method, I added a similar check to have the right column be found:
if (this.Name.Equals(PropertyName.Substring(0, PropertyName.Length - 1)) &&
PropertyName.EndsWith("X") &&
this.Columns.Any(x => x.Name == PropertyName.Substring(0, PropertyName.Length - 1)))
{PropertyName = PropertyName.Substring(0, PropertyName.Length - 1); }
Not sure this is up to snuff, but hey - it works and I get to go home. Cheers!
The text was updated successfully, but these errors were encountered: