PDA

View Full Version : Having trouble creating a custom entity class(object)



jesskuzlo
05-13-2011, 03:20 AM
How would I create my custom Role class based on that autogenerated class? I have read a few articles on the net but I am still lost. Can someone please show me how to do this, and what I must import(using visual basic). I want to add some validation to the string property where Role1 cannot be more than 50 characters.
Autogenerated class

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="CulminITIMSModel", Name:="Role")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
Public Partial Class Role
Inherits EntityObject
#Region "Factory Method"

''' <summary>
''' Create a new Role object.
''' </summary>
''' <param name="roleID">Initial value of the RoleID property.</param>
''' <param name="role1">Initial value of the Role1 property.</param>
Public Shared Function CreateRole(roleID As Global.System.Int32, role1 As Global.System.String) As Role
Dim role as Role = New Role
role.RoleID = roleID
role.Role1 = role1
Return role
End Function

#End Region
#Region "Primitive Properties"

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
<DataMemberAttribute()>
Public Property RoleID() As Global.System.Int32
Get
Return _RoleID
End Get
Set
If (_RoleID <> Value) Then
OnRoleIDChanging(value)
ReportPropertyChanging("RoleID")
_RoleID = StructuralObject.SetValidValue(value)
ReportPropertyChanged("RoleID")
OnRoleIDChanged()
End If
End Set
End Property

Private _RoleID As Global.System.Int32
Private Partial Sub OnRoleIDChanging(value As Global.System.Int32)
End Sub

Private Partial Sub OnRoleIDChanged()
End Sub

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
<DataMemberAttribute()>
Public Property Role1() As Global.System.String
Get
Return _Role1
End Get
Set
OnRole1Changing(value)
ReportPropertyChanging("Role1")
_Role1 = StructuralObject.SetValidValue(value, false)
ReportPropertyChanged("Role1")
OnRole1Changed()
End Set
End Property

Private _Role1 As Global.System.String
Private Partial Sub OnRole1Changing(value As Global.System.String)
End Sub

Private Partial Sub OnRole1Changed()
End Sub

#End Region
#Region "Navigation Properties"

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<XmlIgnoreAttribute()>
<SoapIgnoreAttribute()>
<DataMemberAttribute()>
<EdmRelationshipNavigationPropertyAttribute("CulminITIMSModel", "FK_Users_Roles", "Users")>
Public Property Users() As EntityCollection(Of User)
Get
Return CType(Me,IEntityWithRelationships).RelationshipManager.GetRelatedCollection (Of User)("CulminITIMSModel.FK_Users_Roles", "Users")
End Get
Set
If (Not value Is Nothing)
CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedCollection(O f User)("CulminITIMSModel.FK_Users_Roles", "Users", value)
End If
End Set
End Property

#End Region
End Class