I have an entity that exposes a property "ReadOnly". Because this is an reserved keyword in VB, the IDE throws an error.
I think a simple solution is to put the name of the property between brackets:
Public Overridable Property [Readonly] As Integer
for just C#/VB.NET keywords of all of them.
Regards,
Erik
7 Answers, 1 is accepted
How you have added this property to your model? Did you add it on hand via the add property option in the dsl designer? If that is the case please be aware that currently we are not validating user added properties. At the moment we validate (and correct where needed) properties that are added when you reverse map an already existing table. So for example if in your database you had a column ReadOnly you would have gotten __readOnly for field and _ReadOnly for property names.
Greetings,Petar
the Telerik team
No, it's is a column in my database table (sql server) (ReadOnly as bit)
I did not add it, the model creates the entity with the property name "ReadOnly".
I do update from database, and then the property "ReadOnly" is created by the model, what of course triggers an error, because it is a reserved word in VB.NET. When put between brackets [ReadOnly] this would not be the case.
Thanks,
Erik
I have exactly the same setup. I have a column of type bit that is named ReadOnly in my database. I am using two approaches when I try to reproduce your case.
1. I reverse map the table from the start.
2. I update my model after intentionally skipping the ReadOnly column on the first adding.
Both approaches produce this result:
Private
__readOnly
As
Boolean
Public
Overridable
Property
_ReadOnly
As
Boolean
Get
Return
Me
.__readOnly
End
Get
Set
(
ByVal
value
As
Boolean
)
Me
.__readOnly = value
End
Set
End
Property
Petar
the Telerik team
In my build 325 I created a new proj, add a new model with a table Test and a field ReadOnly. Then I get __ReadOnly as a property. So far so good... Then I add a new field in sql server, call it "Function" and do a "Update from database" in de model. Then I get Function and not _Function:
Private
__ReadOnly
As
String
Public
Overridable
Property
_ReadOnly
As
String
Get
Return
Me
.__ReadOnly
End
Get
Set
(
ByVal
value
As
String
)
Me
.__ReadOnly = value
End
Set
End
Property
Private
_Function
As
Boolean
?
Public
Overridable
Property
Function
As
Boolean
?
Get
Return
Me
._Function
End
Get
Set
(
ByVal
value
As
Boolean
?)
Me
._Function = value
End
Set
End
Property
So, it seems to be a problem with the update from db feature...
I have managed to reproduce the false behavior you have encountered and we will address it as soon as possible. Thank you for your help and please find your Telerik points updated for bringing this issue to our attention.
Regards,Petar
the Telerik team
Hi Petar,
Great! that's fine.
But my question remains... why not put in between brackets (Public Property [Readonly] as Boolean)?
now I can't find my property... (not realy of course)
Regards,
Erik
Currently if the provided identifier is not valid it will be prepended with an underscore. I am afraid that for time being we do not use language specific escape characters to escape the invalid identifier.
I am sorry for the inconvenience caused.
Regards,
Damyan Bogoev
the Telerik team