Sorry about that, posted before I was done. Ignore previous, here's the official one.
Victor,
You can rename a property, but I think you're going to be in trouble if the column uses a keyword. I've successfully renamed a non-keyword column to a keyword (renamed the cust_suffix column in the Customers table in sample db to "class", then bound a control to the "class" field and it loaded and saved). However, in looking at the designer code, I think you'll get into trouble if the column is a keyword.
While you can completely customize the property code, the column name is used in several places, in order to enumerate the columns in the table. Most of them are strings (like the AllFieldNames property). But in three places that I found, a keyword won't be liked. The first is in the definition of the fields enum (names like CustomersBOFieldNames for the CustomersBO). You'd end up with something like:
public enum CustomersBOFieldName
{
cust_ID,
cust_firstName,
void
}
The compiler isn't going to like that keyword in the enum.
The second and third places use the field names enum. One is in the definition of the _FieldEnums dictionary and the other is in defining the property descriptors in the FieldDescriptor property. Now if you remember, you could just manually edit the designer file and slap an @ in front of the enum def and you'd be good to go. Not great, but it would work.
If you decide to try renaming the property it is pretty easy. There are two steps:
1. Using the Bo mapper, define the code of the property, renaming it in the process.
2. (renamed property doesn't match the column name in table) In the BO file (not the designer file), but the regular one, define a property descriptor for the renamed property.
(column is a keyword, so property name is same as column name is table) put an @ in front of column name in _FieldEnums def.
DetailsWhen using the custom code feature, whatever you put in as the custom code is used, as provided when the BO writes out the designer file code. The easiest way to do this is to open an existing BO designer file and copy the code of another property of the same type. Paste it into the custom code area. Use the @ to escape the keyword. Using the same attributes makes sure the field is there for designers etc.
/// <Summary>
/// void field
/// </summary>
[Browsable(false)]
[BusinessFieldDisplayInEditor()]
[Description("void field")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string @void
{
get
{
return (string)this.CurrentRow["void"];
}
set
{
this.CurrentRow["void"] = value;
}
}
This first step you have to do.
As indicated, the second step depends on how you are renaming the property. One possibility (not your case) is that the property has a different name than the column in the table. In this case you'd have to override the GetCustomBindablePropertyDescriptors method and add a descriptor for the renamed property (see help topic "Adding Custom Field Properties"). Likely I wouldn't bother with this, unless there was a really compelling reason that the property couldn't be named as it was in the table. The most likely situation was the requirement to use a base BO that already had a property of the same name of the column.
The other possibility (your case) is that the property isn't really renamed as much as the name is escaped. In this case, you'd have to manually escape the name of the field in _FieldEnums definition, and then I think you'd be good to go. You'd have to remember to do this every time you rebuilt the BO via the BO mapper too. Like I said, not ideal.
I'd likely try the updatable view, as editing designer files like this is a bit of a hack and hard to document. But it's nice to know you have options!