Multiple Result Sets from MockDB

Multiple Result Sets from MockDB

Old forum URL: forums.lhotka.net/forums/t/11766.aspx


CodeWampus posted on Wednesday, January 02, 2013

I am retrieving two records.  Record A has a pointer to Record B.  I could do this with two SQL requests, but for performance reasons I am doing it with one request to a proc that returns the two records as two result sets.  In my business object I am reading the two as follows:

dr.Read()
dr.NextResult()
dr.Read()

This works fine with SQL Server.  However, I am using the CSLA configuration with multiple data sources / DalManager, etc.  I need to know how to return multiple result sets from my mock database.  To return a single record, I would use something like this:

 Public Function Fetch(ByVal TicketBarcode As String) As IDataReader Implements IEventTicketDal.Fetch
Return New ListDataReader(Of EventTicketData)(MockDB.EventTicket.Where(Function(r) r.TicketBarcode = TicketBarcode))
End Function

How would I modify this to return multiple result sets?

CodeWampus replied on Monday, January 07, 2013

I examined the code for ListDataReader, and found that while it had a NextResult() function, it was hard-coded to return a value of False.

After some quick, abortive attempts to program my own NextResult() function, I gave up and modified the code in the business class to check the config file settting for DalManagerType and take alternative action if it was the MockDB, i.e. read first one record, then the other.

Copyright (c) Marimer LLC