locked
Separating BLL and DAL When Not Using Classes RRS feed

  • Question

  • User-1488244059 posted

    I'm implementing n-tier structure in the current app I'm working on. Because DataBinding a list of my Objects to a Repeater was far too slow I need to databind a DataTable to the Repeater.

    Should I still DataBind to a Function (that returns a DataTable) in the BLL that calls a Function in the DAL that returns a DataTable?

    Wednesday, March 9, 2011 6:42 AM

Answers

  • User-525215917 posted

    It seems to me you have some bad design decision made in your object model and this is why data binding is slow. Using ADO.NET objects directly doesn't lead you to good object-oriented design. Can you show some example of your repeater and classes you are binding to it?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 9, 2011 3:03 PM

All replies

  • User-525215917 posted

    It seems to me you have some bad design decision made in your object model and this is why data binding is slow. Using ADO.NET objects directly doesn't lead you to good object-oriented design. Can you show some example of your repeater and classes you are binding to it?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 9, 2011 3:03 PM
  • User-1488244059 posted

    Thanks DigiMortal

    It seems to me you have some bad design decision made in your object model and this is why data binding is slow.

    I think this is the key. It was possible to run a report that would return over 6000 results and these were being displayed on screen in one go. I've since found out how to use paging with the repeater so I can limit the results to a sensible amount.

    Using ADO.NET objects directly doesn't lead you to good object-oriented design.

    I thought this might be the case. I had kept them separate but now I've sorted my original problem I this is isn't an issue any more.

    This is what the repeater looks like now and the class is listed below this....

    <asp:Repeater runat="server" ID="uxClientsRepeater">
        
        <HeaderTemplate>
        
            <table class="ReportResultsTable">  
            <tr>
                <th colspan="2">
                    <asp:Label runat="server" ID="uxSearchResultsCountLabel"></asp:Label>
                </th>
                <th colspan="2">
                    <asp:Label runat="server" ID="uxCurrentPageNumberLabel"></asp:Label>
                    &nbsp;
                    <asp:Button runat="server" ID="uxPreviousPageButton" Text=" Previous " CommandName="Paging" CommandArgument="Previous" />
                    &nbsp;
                    <asp:Button runat="server" ID="uxNextPageButton" Text=" Next " CommandName="Paging" CommandArgument="Next" />
                </th>
                <th colspan="3"></th>
            </tr>
                        
            <tr>
                <th colspan="2"><asp:Label runat="server" ID="uxClientNameLabel">Client</asp:Label></th>
                <th><asp:Label runat="server" ID="uxClientCodeLabel">Client&nbsp;Code</asp:Label></th>
                <th><asp:Label runat="server" ID="uxClientFamilyNameLabel">Client&nbsp;Family</asp:Label></th>
                <th><asp:Label runat="server" ID="uxNumberOfPursuitsLabel">&#35;&nbsp;Pursuits</asp:Label></th>
                <th><asp:Label runat="server" ID="uxClientMarketSectorLabel">Market&nbsp;Sector</asp:Label></th>
                <th><asp:Label runat="server" ID="uxClientApprovedLabel">Approved</asp:Label></th>
            </tr>
            
        </HeaderTemplate>
        
        <ItemTemplate>
        
            <tr>
                <td class="WordWrap" colspan="2"><a href="ViewClient.aspx?c=<%#DataBinder.Eval(Container.DataItem, "ClientID")%>"><%#DataBinder.Eval(Container.DataItem, "ClientName")%></a></td>
                <td><%#DataBinder.Eval(Container.DataItem, "ClientCode")%></td>
                <td><a href="ViewClientFamily.aspx?cf=<%#DataBinder.Eval(Container.DataItem, "ClientFamilyID")%>"><%#DataBinder.Eval(Container.DataItem, "ClientFamily.ClientFamilyName")%></a></td>
                <td style="text-align:center;"><%#DisplayNumberOfPursuits(Container.DataItem) %></td>
                <td><%#DataBinder.Eval(Container.DataItem, "MarketSector.Name")%></td>
                <td style="text-align:center;"><asp:Image runat="server" ID="uxClientyApprovedImage" ImageUrl='<%#DisplayClientApproved(Container.DataItem)%>' /></td>
            </tr>
        
        </ItemTemplate>
        
        <AlternatingItemTemplate>
        
            <tr class="AlternateRow">
                <td class="WordWrap" colspan="2"><a href="ViewClient.aspx?c=<%#DataBinder.Eval(Container.DataItem, "ClientID")%>"><%#DataBinder.Eval(Container.DataItem, "ClientName")%></a></td>
                <td><%#DataBinder.Eval(Container.DataItem, "ClientCode")%></td>
                <td><a href="ViewClientFamily.aspx?cf=<%#DataBinder.Eval(Container.DataItem, "ClientFamilyID")%>"><%#DataBinder.Eval(Container.DataItem, "ClientFamily.ClientFamilyName")%></a></td>
                <td style="text-align:center;"><%#DisplayNumberOfPursuits(Container.DataItem) %></td>
                <td><%#DataBinder.Eval(Container.DataItem, "MarketSector.Name")%></td>
                <td style="text-align:center;"><asp:Image runat="server" ID="uxClientyApprovedImage" ImageUrl='<%#DisplayClientApproved(Container.DataItem)%>' /></td>
            </tr>
            
        </AlternatingItemTemplate>
        
        <FooterTemplate>
        
            </table>
        
        </FooterTemplate>
    
    </asp:Repeater>
        <Serializable()> Public Class Client
    
            Private _clientID As Integer
            Private _clientCode As String
            Private _clientName As String
            Private _clientFamilyID As Integer
            Private _clientFamily As New ClientFamily
            Private _approved As Boolean
            Private _marketSectorID As Integer
            Private _marketSector As New MarketSector
            Private _externalClientReference As String
            Private _sourceSystem As String
            Private _numberOfPursuits As Integer
    
            Public Property ClientID() As Integer
                Get
                    Return _clientID
                End Get
                Set(ByVal value As Integer)
                    _clientID = value
                End Set
            End Property
    
            Public Property ClientCode() As String
                Get
                    Return _clientCode
                End Get
                Set(ByVal value As String)
                    _clientCode = value
                End Set
            End Property
    
            Public Property ClientName() As String
                Get
                    Return _clientName
                End Get
                Set(ByVal value As String)
                    _clientName = value
                End Set
            End Property
    
            Public Property ClientFamilyID() As Integer
                Get
                    Return _clientFamilyID
                End Get
                Set(ByVal value As Integer)
                    _clientFamilyID = value
                End Set
            End Property
    
            Public Property ClientFamily() As ClientFamily
                Get
                    If _clientFamilyID <> Nothing Then
                        _clientFamily = ClientFamily.GetClientFamily(_clientFamilyID)
                        Return _clientFamily
                    Else
                        Return _clientFamily
                    End If
                End Get
                Set(ByVal value As ClientFamily)
                    _clientFamily = value
                End Set
            End Property
    
            Public Property Approved() As Boolean
                Get
                    Return _approved
                End Get
                Set(ByVal value As Boolean)
                    _approved = value
                End Set
            End Property
    
            Public Property MarketSectorID() As Integer
                Get
                    Return _marketSectorID
                End Get
                Set(ByVal value As Integer)
                    _marketSectorID = value
                End Set
            End Property
    
            Public Property MarketSector() As MarketSector
                Get
                    If _marketSectorID <> Nothing Then
                        _marketSector = MarketSector.GetMarketSector(_marketSectorID)
                        Return _marketSector
                    Else
                        Return _marketSector
                    End If
                End Get
                Set(ByVal value As MarketSector)
                    _marketSector = value
                End Set
            End Property
    
            Public Property ExternalClientReference() As String
                Get
                    Return _externalClientReference
                End Get
                Set(ByVal value As String)
                    _externalClientReference = value
                End Set
            End Property
    
            Public Property SourceSystem() As String
                Get
                    Return _SourceSystem
                End Get
                Set(ByVal value As String)
                    _SourceSystem = value
                End Set
            End Property
    
            Public Property NumberOfPursuits() As Integer
                Get
                    Return _numberOfPursuits
                End Get
                Set(ByVal value As Integer)
                    _numberOfPursuits = value
                End Set
            End Property
    
            Public Enum ClientApprovedStatus
                Approved
                NotApproved
                All
            End Enum
    
            ''' <summary>
            ''' Create an instance of a Client
            ''' </summary>
            ''' <remarks></remarks>
            Public Sub New()
    
            End Sub
    
            Public Sub New(ByVal clientID As Integer, ByVal clientCode As String, ByVal clientName As String, ByVal clientFamilyID As Integer, ByVal approved As Boolean, ByVal marketSectorID As Integer, ByVal externalClientReference As String, ByVal sourceSystem As String)
    
                _clientID = clientID
                _clientCode = clientCode
                _clientName = clientName
                _clientFamilyID = clientFamilyID
                _approved = approved
                _marketSectorID = marketSectorID
                _externalClientReference = externalClientReference
                _sourceSystem = sourceSystem
    
            End Sub
    
            ''' <summary>
            ''' Update a particular Client, validating data
            ''' </summary>
            ''' <remarks></remarks>
            Public Shared Sub UpdateClient(ByVal clientToUpdate As AECOM.Client)
    
                clientToUpdate.Save()
    
            End Sub
    
            Private Sub Save()
    
                Dim clientDataAccessLayer As New ClientDAO
    
                If _clientID > 0 Then
                    '   Updating an existing Client
                    clientDataAccessLayer.UpdateClient(Me)
                Else
                    '   Inserting a new Client
                    'clientDataAccessLayer.InsertClient(Me)
                End If
    
            End Sub
    
            ''' <summary>
            ''' Update a particular Client, validating data
            ''' </summary>
            ''' <remarks></remarks>
            Public Shared Sub DeleteClient(ByVal clientID As Integer)
    
                Dim clientDataAccessLayer As New ClientDAO
                clientDataAccessLayer.DeleteClient(clientID)
    
            End Sub
    
            ''' <summary>
            ''' Gets a list of all Clients depending on whether they are approved or not
            ''' </summary>
            ''' <param name="clientAprovedStatus"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function GetClients(ByVal clientAprovedStatus As ClientApprovedStatus) As List(Of Client)
    
                Dim clientDataAccessLayer As New ClientDAO
                Return clientDataAccessLayer.GetClients(clientAprovedStatus)
    
            End Function
    
            Public Shared Function GetClients(ByVal clientAprovedStatus As ClientApprovedStatus, ByVal clientNameSearchText As String) As List(Of Client)
    
                Dim clientDataAccessLayer As New ClientDAO
                Return clientDataAccessLayer.GetClientSearchResults(clientAprovedStatus, clientNameSearchText)
    
            End Function
    
            ''' <summary>
            ''' Gets an individual Client for the given Client ID
            ''' </summary>
            ''' <param name="clientID"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function GetClient(ByVal clientID As Integer) As Client
    
                Dim clientDataAccessLayer As New ClientDAO
                Return clientDataAccessLayer.GetClientByClientID(clientID)
    
            End Function
    
            ''' <summary>
            ''' Gets a list of Clients for a given Client Family ID
            ''' </summary>
            ''' <param name="clientFamilyID"></param>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public Shared Function GetClients(ByVal clientFamilyID As Integer) As List(Of Client)
    
                Dim clientDataAccessLayer As New ClientDAO
                Return clientDataAccessLayer.GetClients(clientFamilyID)
    
            End Function
    
        End Class

    Thursday, March 10, 2011 3:16 AM