Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing enitity data from within base class lib's
Message
From
03/05/2011 12:47:44
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Accessing enitity data from within base class lib's
Miscellaneous
Thread ID:
01509247
Message ID:
01509247
Views:
103
OK I guess I phrased my 1st question wrong. I have three business objects in three separate business projects that share some common functions and data. Note: note all the data is the same .
I want to access those functions and data in my base class library. In order to access the functions I’ve created an interface that has all the methods that are common and I have the three BO’s implement that interface. Works great no problem. The next step is to be able to get at the common data in the entities. This is where everything has come to a grinding halt.
I thought I could do this through another interface. Created an interface that had all the common entity fields and had the three BO’s entity classes implement that interface.
The problem I run into is that I cant cast from the interface implemented by the BO’s to any class that will give me access to the entity or entity list.
Example.

Interfaces in base class Lib
Public Interface IDataCaptureReturn
Function GetEntityListByDLN(Of EntityType As {New, mmBusinessEntity})(ByVal dln As Int64) As mmBindingList(Of EntityType)
End Interface

Public Interface IdataCaptureReturnEntity
    Property DCR_DLN() As Int64
    Property DCR_OperatorID As String
    Property DCR_VoidInd As Boolean
End Interface
BO’s


CTV Business
Partial Public Class DataCaptureReturn

    Implements IDataCaptureReturn


Public Function GetEntityListbyDLN(Of EntityType As {New, mmBusinessEntity})(ByVal dln As Long) As mmBindingList(Of EntityType) Implements IDataCaptureReturn.GetEntityListByDLN
        Dim paramDLN As IDbDataParameter = Me.CreateParameter("@DLN", dln)
        ' Me.GetEntityList("DataCaptureReturnByDLN", Me.DatabaseKey, CommandType.StoredProcedure, paramDLN)
        Return Me.GetEntityList(Of EntityType)("DataCaptureReturnByDLN", Me.DatabaseKey, CommandType.StoredProcedure, paramDLN)
        Return Me.EntityList
    End Function

End class


Partial Public Class DataCaptureReturnEntity
    Inherits ABusinessEntity
    Implements IdataCaptureReturnEntity
  Public Property DCR_DLN() As Int64 Implements IdataCaptureReturnEntity.DCR_DLN
        Get
            If Not Me.Row Is Nothing Then
                Return CType(mmType.GetNonNullableDbValue(Me.Row("DCR_DLN"), "System.Int64"), System.Int64)
            Else
                Return Me._DCR_DLN
            End If
        End Get
        Set(ByVal value As Int64)
            If Not Me.Row Is Nothing Then
                Me.Row("DCR_DLN") = Value
            End If
            Me._DCR_DLN = Value
            Me.OnPropertyChanged(New PropertyChangedEventArgs("DCR_DLN"))
        End Set
    End Property
	Private _DCR_DLN As Int64

End class
Abstract class in base class Lib
Public Class DoStuffBase
Dim oDataCap as IDataCaptureReturn
Public Sub New()
initBO()
me.DoStuff
EndSub
 Protected Overidable Public Class DoStuffBase
End Sub

Private sub DoStuff()
Me.oDataCap.GetEntityListbyDLN GetEntityListbyDLN(Of mmBusinessEntity)
 (1234) 
‘this will throw a casting error
Dim mmReturnData As mmBusinessObjectGeneric(Of mmBusinessEntity) = CType(Me. oDataCap, mmBusinessObjectGeneric(Of mmBusinessEntity))
        Dim oEntity As IdataCaptureReturnEntity = CType(mmReturnData.Entity, IdataCaptureReturnEntity)
 endsub
End class
Concrete Class
Imports CTVBusiness
Imports Lockbox.Base
 Public Class DoStuff
Inhiertits DoStuffBase
Protected overrides sub initBO()
	Me.oDataCap = new DataCaptureReturn
End sub
End class
Is thier another approach I should be using?
Next
Reply
Map
View

Click here to load this message in the networking platform