StrataFrame Forum

Errr on Changing DBFieldName to get readable propertyName

http://forum.strataframe.net/Topic14384.aspx

By Ertan Deniz - 2/14/2008

I've followed the process below ;

Using Object Mapper , Select the field and press Customize,

Check Use Custom Code and Create Descriptor,

Paste the code (Change only cust_firstname to FirstName) below in the custom code section;

I've got the error below.

"An error occurred while refreshing the data from field 'CustomerBase.FirstName' to property 'Text' on control 'TextEdit1.'  Are you missing FieldPropertyDescriptor for a custom property?"

 But this is not custom property. What is missing ?

----------------

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("cust_FirstName"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [FirstName]() As System.String

Get

Return CType(Me.CurrentRow.Item("cust_FirstName"), System.String)

End Get

Set(ByVal value As System.String)

Me.CurrentRow.Item("cust_FirstName") = value

End Set

I've

 

By Ertan Deniz - 2/14/2008

When Create Descriptor option is selected in ObjectMapper, I've got syntax error (member not found) with functions GetValue and SetValue (designer.vb). Because, I've changed cust_FirstName to FirstName by Custom Code.

Public Overrides Function GetValue(ByVal component As Object) As Object

Return CType(component, CustomerBase).cust_FirstName

End Function

Public Overrides Sub SetValue(ByVal component As Object, ByVal Value As Object)

CType(component, CustomerBase).cust_FirstName = CType(Value, System.String)

End Sub

By Trent L. Taylor - 2/14/2008

with functions GetValue and SetValue (designer.vb). Because, I've changed cust_FirstName to FirstName by Custom Code.

It sounds as though you have answered your own question here.  A property descriptor is created by the BO Mapper for each field.  If you do not want to use the property name assigned by the schema of the table and create a custom property, then either create a separate property or use the custom code option in the BO Mapper.  You can then manually add a ReflectionPropertyDescriptor by overriding the GetCustomBindablePropertyDescriptors method of the BO.  There are many posts related to this:

http://forum.strataframe.net/FindPost13027.aspx

http://forum.strataframe.net/FindPost3584.aspx

There is also documentation in this regard.  But if you just go and start changing the generated field name without using the "custom code" option in the mapper, then you are going to have downstream effects like this.

By Ertan Deniz - 2/14/2008

I've used Custom Code option. Copy the only property related code from (designer.vb) and paste it into Custom code section.

In Custom code section, I've changed property name to a more readable form, Then build partial class. I've also added an override for the GetCustomBindablePropertyDescriptors() function. But I've got known error. This was my process.

I want to use the property (with new name) generated by Mapper. I don't want to define new custom properties for each field. This is the my case.

I've seen that If Only property descriptor was pasted into custom code region, field descriptor class remained the same with old property names after generation.

By Trent L. Taylor - 2/14/2008

I think that you are wanting a feature in the BO Mapper that will allow you to override the name of the field without having to create a custom property for each item...I think Smile  This is already on an enhancement list for a future release.  Past that, if you want to send me a sample to reproduce what you are talking about then that would be great.  I am having a hard time following what you are getting at here.  Thanks.
By Ertan Deniz - 2/14/2008

New feature is simply implement by getting friendly name for the field. Then generate according to this.

There must be no need to write anything.

My situation works well. I've have pasted standart property code with changed name into custom code, not selected the option 'Create descriptor' and written code that overrides GetCustomBindablePropertyDescriptors for the property.

By Greg McGuffey - 2/15/2008

This is already on an enhancement list for a future release.




How "future"? I've run into another instance were this would be really, really handy (inserting the user friendly field name into broken rule messages).
By Trent L. Taylor - 2/15/2008

How "future"? I've run into another instance were this would be really, really handy (inserting the user friendly field name into broken rule messages).

Depending on the complications, this may be in the 1.6.5 build....emphasis on "maybe." Smile

By Greg McGuffey - 2/15/2008

BigGrin Got it. I'm crossing my fingers!