Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing enitity data from within base class lib's
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01509247
Message ID:
01509499
Vues:
57
Brian,

When you say all the data is the same, does that mean that all business objects have the same default business entity type? If so, rather than specifying a generic mmBusinessEntity, you can specify the exact entity type.


>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?
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform