AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

How to add a custom Property Attribute to my VB.NET Entity #254

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have got a Property in my Entity with the Name:

AccNoatCust

If there is an error for example field length or nothing in it, I would 
like to display a more user friendly Name e.g "Account Number at Customer"
or for colFundName --> "Fund Name"

Same for my Audit trail, I would like to show a list of Items which have 
changed, showing the field before and after the change. Having my system 
names like mentioned above this is not very helpfull for the user.

I found out how to add an Error Message like:

<Required(ErrorMessage:="Please enter Fund Name.")> _
<StringLength(200, ErrorMessage:="Fund Name is only allowed to have a 
length of 1-200 Characters")>

Btw. This is a bug within Plinqo. If I don't add a custom Error Message to 
my Property, the BrokenRuleException Returns: FundName should have 0-200 
but it should be 1-200 if it is a required field and nothing was entered.

Currently I added something like:

 ''' <summary>
'''    Custom attribute class to add a more descriptive Fieldname to a 
Property
''' </summary>
''' <remarks>
'''     
''' </remarks>
Public Class FieldNameAttribute

    Inherits Attribute

    Private m_FieldName As String

    Public ReadOnly Property FieldName() As String
        Get
            Return m_FieldName
        End Get
    End Property

    Public Sub New(ByVal FieldName As String)
        Me.m_FieldName = FieldName
    End Sub

End Class

But If I have a look to my Entity via reflexion I'm not able to see this 
Custom Attribute.

Could you implement something within Plinqo to add a custom field name or 
give me a hint how to do it?

Best thing would be an option to switch on/off if someone wants custom 
names within the cst file.

Original issue reported on code.google.com by schaffn...@GMX.de on 9 Feb 2010 at 1:52

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 12 Feb 2010 at 2:51

GoogleCodeExporter commented 9 years ago
I created a patched Plinqo Version 1382 for VB.NET. If you please could have a 
look 
at it?
With this Version you are able to add a Description Attribute to the Generated 
Entity. The Attribute gets filled by a Class collection of String Constants.

The Constants are editable and are not overwritten. Only thing which is 
missing, if 
I add a new Column to a table the new Constant is not produced, I hope you 
could 
give me a hint? I also have a problem with views of stored procedures....

The Description Attribute is visible via Reflection.
What do you think about it?

Original comment by schaffn...@GMX.de on 19 Feb 2010 at 1:02

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 23 Apr 2010 at 3:41

GoogleCodeExporter commented 9 years ago
Hi this is from 2010, are you still investigating? Does something happen here? 
I would like to see also a "more user friendly Name"

Original comment by Athur...@GMX.de on 14 May 2013 at 10:19

GoogleCodeExporter commented 9 years ago
Hello,

My apologies. This was marked as investigating but we got side tracked on other 
tasks. I'll try and take a look into this soon and get it applied to core. If 
you could apply the patch and let us know how it works out for you that would 
be appreciated.

Original comment by bniemyjski on 14 May 2013 at 10:20

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 14 May 2013 at 10:20