/
FieldMappingAttribute.vb
executable file
·63 lines (52 loc) · 2.06 KB
/
FieldMappingAttribute.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
' ___________________________________________________
'
' © Hi-Integrity Systems 2010. All rights reserved.
' www.hisystems.com.au - Toby Wicks
' ___________________________________________________
'
''' --------------------------------------------------------------------------------
''' <summary>
''' The FieldMappingAttribute class is used to define a mapping between a database
''' field and a class property. This attribute is used with the
''' DatabaseObjectUsingAttributes class.
''' This field can also be used for loading fields that are of type
''' DatabaseObjects.ObjectReference or DatabaseObjects.Generic.ObjectReference.
''' </summary>
''' --------------------------------------------------------------------------------
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False, Inherited:=True)> _
Public Class FieldMappingAttribute
Inherits Attribute
Private pstrFieldName As String
''' --------------------------------------------------------------------------------
''' <param name="strFieldName">
''' The name of the database field associated with this property or field.
''' </param>
''' <example>
''' Loads a field:
''' <code>
'''
''' <DatabaseObjects.FieldMapping("Name")> _
''' Private pstrName As String
'''
''' </code>
''' Loads an object:
''' <code>
'''
''' <DatabaseObjects.FieldMapping("ProductGroupID")> _
''' Private pobjGroup As New Generic.ObjectReference(Of ProductGroup, Integer)(Database.ProductGroups)
'''
''' </code>
''' </example>
''' --------------------------------------------------------------------------------
Public Sub New(ByVal strFieldName As String)
If strFieldName = String.Empty Then
Throw New ArgumentNullException
End If
pstrFieldName = strFieldName
End Sub
Public ReadOnly Property FieldName() As String
Get
Return pstrFieldName
End Get
End Property
End Class