filtering a created dataset

hi everyone

i have been working on a three tier application composed of a DAL a BLL and an XML presentation layer however i seem to have come to an impass and i was wondering if any of you helpful people out there can assist me.

I have created a XML_ view class that calls a function in the BLL wish in turn drills down into the DAL and returns a dataset. this is the code i use in the XML view and the BLL

XML class

PublicClass claimwatch_xml

Inherits BaseclaimBLL

Dim sitecodeAsString

'this class defines the fieldname aliases for the claim watch data extract

Dim baseclaimlogicAsNew BaseclaimBLL

Dim baseclaimdata = baseclaimlogic.filterbaseclaim(sitecode)

EndClass

BLL

PublicClass BaseclaimBLL

Private _baseclaimadapterAs BaseClaimTableAdapter =Nothing

ProtectedReadOnlyProperty adapter()As BaseClaimTableAdapter

Get

If _baseclaimadapterIsNothingThen

_baseclaimadapter =New BaseClaimTableAdapter

EndIf

Return _baseclaimadapter

EndGet

EndProperty

PublicFunction Fillbaseclaimbysitecode(ByVal sitecodeAsString)As active_web_dataset.BaseClaimDataTable

Return adapter.GetDatasitecode_extract(sitecode)

EndFunction

PublicFunction filterbaseclaim(ByVal sitecodeAsString)

'function filters baseclaim dataset based on certain criteria

Dim baseclaimAs active_web_dataset.BaseClaimDataTable = adapter.GetDatasitecode_extract(sitecode)

If baseclaim.Count = 0Then

ReturnFalse

EndIf

'put in filtering code here

Return baseclaim

EndFunction

normally to filter the data comming up from the DaL i would simply create a query in the DAL and wrap it in a function in the BLL however the client wants only generic slect queries in the DAL and i need to filter the resultant dataset in the BLL before passing it up to the XML_view class.

typical filtering i need to do is for example where one row in baseclaim is not null or is greater than the other

any ideas please ?

regards

lee

[4256 byte] By [ProfLeeHubbard] at [2008-1-10]
# 1

Hi,

It is unfortunate the client only wants generic select statements in the DAL because it does mean that there is a certain amount of unrequired data being passed up to your Business layer. If there is a wire between the DAL and BLL then there will be a bit of a performance hit.

However I don't think you can help this so the approach I would take would be to use the DataView class, within the BLL, to wrap around the data tables. From this DataView you can then return a DataTable of filtered records. Here is a pseudocode example based on your code...

Public Function filterbaseclaim(ByVal sitecode As String)

'function filters baseclaim dataset based on certain criteria

Dim baseclaim As active_web_dataset.BaseClaimDataTable = adapter.GetDatasitecode_extract(sitecode)

If baseclaim.Count = 0 Then

Return False

End If

'put in filtering code here

Dim filteredView as new DataView(baseclaim, "[Column] <> Nothing")

Return Ctype(filteredView.ToTable(), active_web_dataset.BaseClaimDataTable)

End Function

That filter expression is not correct, but it demonstrates the idea. The advantage is, and this is new to .NET v2.0, you can return the filtered view as a stand alone table so the presentation layer should require little to no changes, it's still recieving a data table object.

DerekSmyth at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic IDE...
# 2

Dear Derek

Many thanks for your reply it was really helpful and has pointed me in the right direction. It is unfortunate that the client wants the DAL to be so generic but thats clients for you. Now i have to write and XML schema to wrap the extracted data and post it out...oh joy!!

again many thanks and cheers

regards

lee

ProfLeeHubbard at 2007-10-3 > top of Msdn Tech,Visual Basic,Visual Basic IDE...