У меня ошибка в следующем классе, но я не уверен, где это.Класс будет корректно возвращаться в моем сервисе, но не сериализуется и не даст никаких результатов.Любая помощь будет принята с благодарностью.
Imports System
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses
Imports System.Data.EntityClient
Imports System.ComponentModel
Imports System.Xml.Serialization
Imports System.Runtime.Serialization
' <summary>
'<para>This class is used to load Email objects.</para>
' <para>
' CreateDate: 6-14-2011
' ModifyDate: 6-14-2011
' ModifyDesc: Initial Creation
' </para>
' </summary>
'
#Region "Email"
''' <summary>
''' Email class.
''' </summary>
<DataContractAttribute(IsReference:=True)>
<KnownTypeAttribute(GetType(CompanyLocEmail))>
<KnownTypeAttribute(GetType(CompanyEmail))>
<KnownTypeAttribute(GetType(UserEmail))>
Partial Public MustInherit Class Email
#Region "Declarations"
<DataMemberAttribute()>
Private _IsPreferred As Nullable(Of Global.System.Boolean)
<DataMemberAttribute()>
Private _EmailTypeL As Global.System.String
<DataMemberAttribute()>
Private _EmailTypeS As Global.System.String
<DataMemberAttribute()>
Private _EmailAddress As Global.System.String
<DataMemberAttribute()>
Private _XID As Global.System.Int32
<DataMemberAttribute()>
Private _EID As Global.System.Int32
#End Region
#Region "Primitive Properties"
#Region "IsPreferred"
''' <summary>
''' IsPrefferred.
''' </summary>
Public Property IsPreferred() As Nullable(Of Global.System.Boolean)
Get
Return _IsPreferred
End Get
Set(value As Nullable(Of Global.System.Boolean))
OnIsPreferredChanging(value)
_IsPreferred = value
OnIsPreferredChanged()
End Set
End Property
Partial Private Sub OnIsPreferredChanging(value As Nullable(Of Global.System.Boolean))
End Sub
Partial Private Sub OnIsPreferredChanged()
End Sub
#End Region
#Region "EmailTypeL"
''' <summary>
''' EmailTypeL.
''' </summary>
Public Property EmailTypeL() As Global.System.String
Get
Return _EmailTypeL
End Get
Set(value As Global.System.String)
OnEmailTypeLChanging(value)
_EmailTypeL = value
OnEmailTypeLChanged()
End Set
End Property
Partial Private Sub OnEmailTypeLChanging(value As Global.System.String)
End Sub
Partial Private Sub OnEmailTypeLChanged()
End Sub
#End Region
#Region "EmailTypsS"
''' <summary>
''' EmailTypeS.
''' </summary>
Public Property EmailTypeS() As Global.System.String
Get
Return _EmailTypeS
End Get
Set(value As Global.System.String)
OnEmailTypeSChanging(value)
_EmailTypeS = value
OnEmailTypeSChanged()
End Set
End Property
Partial Private Sub OnEmailTypeSChanging(value As Global.System.String)
End Sub
Partial Private Sub OnEmailTypeSChanged()
End Sub
#End Region
#Region "EmailAddress"
''' <summary>
''' EmailAddress.
''' </summary>
Public Property EmailAddress() As Global.System.String
Get
Return _EmailAddress
End Get
Set(value As Global.System.String)
OnEmailAddressChanging(value)
_EmailAddress = value
OnEmailAddressChanged()
End Set
End Property
Partial Private Sub OnEmailAddressChanging(value As Global.System.String)
End Sub
Partial Private Sub OnEmailAddressChanged()
End Sub
#End Region
#Region "EID"
''' <summary>
''' EID.
''' </summary>
Public Property EID() As Global.System.Int32
Get
Return _EID
End Get
Set(value As Global.System.Int32)
If (_EID <> value) Then
OnEIDChanging(value)
_EID = value
OnEIDChanged()
End If
End Set
End Property
Partial Private Sub OnEIDChanging(value As Global.System.Int32)
End Sub
Partial Private Sub OnEIDChanged()
End Sub
#End Region
#Region "XID"
''' <summary>
''' XID.
''' </summary>
Public Property XID() As Global.System.Int32
Get
Return _XID
End Get
Set(value As Global.System.Int32)
If _XID <> value Then
OnXIDChanging(value)
_XID = value
OnXIDChanged()
End If
End Set
End Property
Partial Private Sub OnXIDChanging(value As Global.System.Int32)
End Sub
Partial Private Sub OnXIDChanged()
End Sub
#End Region
#End Region
End Class
#End Region
#Region "CompanyEmail"
''' <summary>
''' CompanyEmail class.
''' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class CompanyEmail
Inherits Email
#Region "Declarations"
<DataMemberAttribute()>
Private _Company As Company
#End Region
#Region "Factory Method"
''' <summary>
''' Create a new CompanyEmail object.
''' </summary>
''' <param name="emailTypeL">Initial value of the EmailTypeL property.</param>
''' <param name="emailTypeS">Initial value of the EmailTypeS property.</param>
''' <param name="emailAddress">Initial value of the EmailAddress property.</param>
''' <param name="eID">Initial value of the EID property.</param>
''' <param name="xID">Initial value of the XID property.</param>
Public Shared Function CreateCompanyEmail(emailTypeL As Global.System.String, emailTypeS As Global.System.String, emailAddress As Global.System.String, eID As Global.System.Int32, xID As Global.System.Int32) As CompanyEmail
Dim companyEmail As CompanyEmail = New CompanyEmail
companyEmail.EmailTypeL = emailTypeL
companyEmail.EmailTypeS = emailTypeS
companyEmail.EmailAddress = emailAddress
companyEmail.EID = eID
companyEmail.XID = xID
Return companyEmail
End Function
#End Region
#Region "ParentProperties"
<XmlIgnoreAttribute()>
<SoapIgnoreAttribute()>
Public Overridable Property Company() As Company
Get
Return _Company
End Get
Set(value As Company)
_Company = value
End Set
End Property
#End Region
End Class
#End Region
#Region "CompanyLocEmail"
''' <summary>
''' CompanyLocEmail class.
''' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class CompanyLocEmail
Inherits Email
#Region "Declarations"
Private _CompanyLoc As CompanyLoc
#End Region
#Region "Factory Method"
''' <summary>
''' Create a new CompanyLocEmail object.
''' </summary>
''' <param name="emailTypeL">Initial value of the EmailTypeL property.</param>
''' <param name="emailTypeS">Initial value of the EmailTypeS property.</param>
''' <param name="emailAddress">Initial value of the EmailAddress property.</param>
''' <param name="eID">Initial value of the EID property.</param>
''' <param name="xID">Initial value of the XID property.</param>
Public Shared Function CreateCompanyLocEmail(emailTypeL As Global.System.String, emailTypeS As Global.System.String, emailAddress As Global.System.String, eID As Global.System.Int32, xID As Global.System.Int32) As CompanyLocEmail
Dim companyLocEmail As CompanyLocEmail = New CompanyLocEmail
companyLocEmail.EmailTypeL = emailTypeL
companyLocEmail.EmailTypeS = emailTypeS
companyLocEmail.EmailAddress = emailAddress
companyLocEmail.EID = eID
companyLocEmail.XID = xID
Return companyLocEmail
End Function
#End Region
#Region "ParentProperties"
<DataMemberAttribute()>
<XmlIgnoreAttribute()>
<SoapIgnoreAttribute()>
Public Overridable Property CompanyLoc() As CompanyLoc
Get
Return _CompanyLoc
End Get
Set(value As CompanyLoc)
_CompanyLoc = value
End Set
End Property
#End Region
End Class
#End Region
#Region "UserEmail"
''' <summary>
''' UserEmail class.
''' </summary>
<DataContractAttribute(IsReference:=True)>
Partial Public Class UserEmail
Inherits Email
#Region "Declarations"
Private _UserRole As UserRole
#End Region
#Region "Factory Method"
''' <summary>
''' Create a new UserEmail object.
''' </summary>
''' <param name="emailTypeL">Initial value of the EmailTypeL property.</param>
''' <param name="emailTypeS">Initial value of the EmailTypeS property.</param>
''' <param name="emailAddress">Initial value of the EmailAddress property.</param>
''' <param name="eID">Initial value of the EID property.</param>
''' <param name="xID">Initial value of the XID property.</param>
Public Shared Function CreateUserEmail(emailTypeL As Global.System.String, emailTypeS As Global.System.String, emailAddress As Global.System.String, eID As Global.System.Int32, xID As Global.System.Int32) As UserEmail
Dim userEmail As UserEmail = New UserEmail
userEmail.EmailTypeL = emailTypeL
userEmail.EmailTypeS = emailTypeS
userEmail.EmailAddress = emailAddress
userEmail.EID = eID
userEmail.XID = xID
Return userEmail
End Function
#End Region
#Region "ParentProperties"
<DataMemberAttribute()>
<XmlIgnoreAttribute()>
<SoapIgnoreAttribute()>
Public Overridable Property UserRole() As UserRole
Get
Return _UserRole
End Get
Set(value As UserRole)
_UserRole = value
End Set
End Property
#End Region
End Class
#End Region
Определение интерфейса
<OperationContract()> _
Function GetEmail(iID As Integer) As UserEmail
Фактический вызов
Public Function GetEmail(iID As Integer) As UserEmail Implements InsightDataAPIInterface.GetEmail
Dim ret = (From c In db.Emails Where c.EID = iID Select c).Take(1)
Dim y As UserEmail
For Each x In ret
y = CType(x, UserEmail)
Next x
'Breakpoint here shows correct data in y, so y returns the class
Return y
End Function
Это не будет финальная итерация GetEmail, но яЯ использую это в своем текущем состоянии, чтобы попытаться выяснить, почему я не получаю класс для правильной сериализации.Если бы кто-нибудь мог подтолкнуть меня в правильном направлении, я был бы очень в долгу.:)