Creating a BO Base Class...?


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I am working on a project which requires the use of GUID PKs, I am following the good samples in this thread: http://forum.strataframe.net/Topic15854-6-3.aspx?Highlight=NewSequentialId

I created a a base BO class named ApplicationBaseBusinessClass.vb with the following code:

Imports MicroFour.StrataFrame.Business

Imports System.ComponentModel

Imports System.Runtime.Serialization

Public Class ApplicationBaseBusinessClass

Inherits MicroFour.StrataFrame.Business.BusinessLayer

#Region " Private Fields "

Private _PrimaryKeyIsAutoIncremented As Boolean = False

Private _PrimaryKeyIsUpdatable As Boolean = True

#End Region

#Region " Public Properties "

''' <summary>

''' Gets or sets a value that determines whether the primary key for this business object is

''' auto-incremented within the data source (assigned by the database rather than by the

''' client).

''' </summary>

<Category(EDITOR_CATEGORY_CRUD), _

DefaultValue(False)> _

Public Overrides Property PrimaryKeyIsAutoIncremented() As Boolean

Get

Return _PrimaryKeyIsAutoIncremented

End Get

Set(ByVal value As Boolean)

_PrimaryKeyIsAutoIncremented = value

End Set

End Property

''' <summary>

''' Determines if the primary key field is updatable. This property allows primary key fields that are not auto-incrementing to be used while

''' preventing an update error if the field is not updatable (i.e. Guid Primary Keys).

''' </summary>

<Category(EDITOR_CATEGORY_CRUD), _

DefaultValue(True)> _

Public Overrides Property PrimaryKeyIsUpdatable() As Boolean

Get

Return _PrimaryKeyIsUpdatable

End Get

Set(ByVal value As Boolean)

_PrimaryKeyIsUpdatable = value

End Set

End Property

#End Region

#Region " Overridable Subs "

Protected Overrides Sub OnSetDefaultValues()

MyBase.OnSetDefaultValues()

If Me.PrimaryKeyIsUpdatable = True AndAlso Me.PrimaryKeyIsAutoIncremented = False Then

'-- Set Value for GUID PK

'-- Get a reference to the property descriptor (which doesn't use reflection)

Dim loFieldPropDescriptor As FieldPropertyDescriptor = Me.GetPropertyDescriptor(Me.PrimaryKeyField)

'-- If the PK type is a Guid then Generate a Sequential GUID to prevent Index fragmentation

If loFieldPropDescriptor.PropertyType Is GetType(Guid) Then

loFieldPropDescriptor.SetValue(Me, ezCallTrack.Basics.NewSequentialID)

End If

End If

End Sub

#End Region

End Class

I then changed the Ingeritance in my BizCustomer.vb class from:

Inherits MicroFour.StrataFrame.Business.BusinessLayer

To:

Inherits ezCallTrack.Business.ApplicationBaseBusinessClass

Now I am getting a compiler error in my BizCustomer.vb "Too many arguments to Public Sub New()", this is the code created by the BOM that generates the error:

''' <summary>

''' Initializes a new instance of the bizCustomers class.

''' </summary>

''' <param name="info">The SerializationInfo for the object.</param>

''' <param name="context">The StreamingContext for the source stream.</param>

''' <remarks></remarks>

Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)

MyBase.New(info, context)

'This call is required by the Component Designer.

Me.InitializeComponent()

'-- Add the necessary handlers

Me.AddHandlers()

End Sub

Here is the code for the BO bizCustomer.vb

Imports System.Data

Imports System.Data.SqlClient

Imports System.Runtime.Serialization

<Serializable()> _

Public Class bizCustomers

Inherits ezCallTrack.Business.ApplicationBaseBusinessClass

#Region " Constructors "

''' <summary>

''' Initializes a new instance of the bizCustomers class.

''' </summary>

''' <remarks></remarks>

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Sub New()

MyBase.New()

'This call is required by the Component Designer.

Me.InitializeComponent()

'-- Add the necessary handlers

Me.AddHandlers()

End Sub

''' <summary>

''' Initializes a new instance of the bizCustomers class.

''' </summary>

''' <param name="Container">The IContainer to which this object will be added.</param>

''' <remarks></remarks>

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _

Public Sub New(ByVal Container As System.ComponentModel.IContainer)

MyBase.New()

'This call adds the component to the given container.

Container.Add(Me)

'This call is required by the Component Designer.

Me.InitializeComponent()

'-- Add the necessary handlers

Me.AddHandlers()

End Sub

''' <summary>

''' Initializes a new instance of the bizCustomers class.

''' </summary>

''' <param name="info">The SerializationInfo for the object.</param>

''' <param name="context">The StreamingContext for the source stream.</param>

''' <remarks></remarks>

Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)

MyBase.New(info, context)

'This call is required by the Component Designer.

Me.InitializeComponent()

'-- Add the necessary handlers

Me.AddHandlers()

End Sub

''' <summary>

''' Adds the necessary handlers for the bizCustomers class.

''' </summary>

''' <remarks></remarks>

Private Sub AddHandlers()

AddHandler Me.CheckRulesOnCurrentRow, AddressOf bizCustomers_CheckRulesOnCurrentRow

AddHandler Me.SetDefaultValues, AddressOf bizCustomers_SetDefaultValues

End Sub

#End Region

#Region " Data Retrieval Methods "

#End Region

#Region " Event Handlers "

''' <summary>

''' Checks the business rules on the current row

''' </summary>

''' <param name="e"></param>

''' <remarks></remarks>

Private Sub bizCustomers_CheckRulesOnCurrentRow(ByVal e As MicroFour.StrataFrame.Business.CheckRulesEventArgs)

End Sub

''' <summary>

''' Sets the default values for a new row

''' </summary>

''' <remarks></remarks>

Private Sub bizCustomers_SetDefaultValues()

End Sub

#End Region

End Class

What am I doing wrong here?

P.S.

Sorry for the long post.

Edhy Rijo

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