How to add several custom fields to a BO


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Actually, the reason I was looking at an interface was that I have another class (a user control actually) that would interface with the common functionality of the special BOs. I.e. I need to reference the Interface in the other class, so I can call the known methods (the BOs will all have sequencing functionality, like MoveItemUp, MoveItemDown, etc.). Each BO would implement the methods as needed by the particular table.

What I ended up doing was to just create two variables, one as a BusinessLayer item and one as my interface item (IParentSequencerBO). Then provided a single public property for the BusinessLayer variable, set the interface variable to the same object. It seems to be working great. E.g. below in case my narrative is confusing.


Public Class MyClass

private _bo as Microfour.StrataFrame.Business.BusinessLayer
private _seqBO as IParentSequenceBO
private _idField as String

Public Property IDField(fieldName as string)
Get
IDField = _idField
End Get
Set(ByVal value As string)
_idField=value
End Set
End Property

Public Property BO As Microfour.StrataFrame.Business.BusinessLayer
Get
BO = _bo
End Get
Set(ByVal value As Microfour.StrataFrame.Business.BusinessLayer)
_bo = value
_seqBO = value
End Set
End Property

Public Sub MoveDown()
'-- Call a method of the BusinessLayer
Dim id As Int32 = _bo.Item(Me.IDField)

'-- Call a method define by the interface
_seqBO.MoveItemDown(id)
End Sub
End Class


If you have a better idea, I'm all ears.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, what is the correct tag for code snippets. Obviously, the one's I'm using are correct. Sad
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
What you are doing will definitely work.  There are two other things that you could do.  First, tack this on to my first example...create your own interface, as you have, and then associated this interface with your custom BusinessLayer class.  This is more structured and will be much easier to work with as your application grows.

Public Class MyCustomBusinessLayer
    Inherits MicroFour.StrataFrame.Business.BusinessLayer
    Implements IParentSequenceBO
   '-- Add Your Stuff
End Class

As for your code snippet, I edited your post and then saved and it worked. There could be underlying characters that are being pasted in with your code causing the problem.  One thing to do is to paste it into notepad first then copy it from there.  THis way all special characters are stripped.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
That is exactly what I'm doing. I'm going to have half dozen or so BOs that all have this sequencing functionality. With this interface I can build a reusable UI control/component to re-sequence elements within the BO. Though I might suggest that you provide a IBusinessLayer interface in the future. It would make this sort of thing easier. Then I could just inherit that interface for any of my own and life would be grand BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I don't think I can explain this properly over the forum, but there is no need for an IBusinessLayer interface.  An interface is not the solution here...you can use the BusinessLayerBase class, which you will find commonly throughout the framework and in typed editors, etc.  This will give you the base functionality and will allow any type of BO to be handed over to a variable or property typed as this...but I still do not see a need for the IBusinessLayer interface. 
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Trent L. Taylor (11/17/2006)
I don't think I can explain this properly over the forum...




I just wrote out a long explanation of why an IBusinessLayer interface would be helpful when I think I get what you are saying about using a concrete class....



So, I create a new class, lets say ParentSequencerBO. This would not hit any tables right (and thus would always have a red X by it in the BO mapper)? it would look something like:





Public MustInherit Class ParentSequencerBusinessLayer

Inherits BusinessLayer



' Abstract methods...but they could be actual methods too, if code

' could be generalized

Public MustOverride Sub MoveItemUp()

Public MustOverride Sub MoveItemDown()



End Class





Then I would derive my actual BOs from it:





Public Class ProcessStepBO

Inherits ParentSequencerBusinessLayer



Public Overrides Sub MoveItemUp()

' ...code

End Sub

Public Overrides Sub MoveItemDown()

'....code

End Sub

End Class





Then my User control would reference the abstract class ParentSequencerBusinessLayer and I'm good. See, I think you got it across here in the forum (if I'm getting it)! Tongue



P.S. the [codesnippet][/codesnippet] isn't working. I double checked for weird characters, pasted into and out of a text editor...but no joy. Maybe it is user permission thing?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search