I want to build a RiderInfoList object and am lost on how to implement the Child_Fetch method to call from the list's Fetch method:

private void Child_Fetch(System.Data.IDataReader data)

Thanks

RockfordLhotka replied on Thursday, April 28, 2011

RiderInfo is a read-only object, and RiderInfoList is a read-only list of RiderInfo?

Normally you'd do the database query in the RiderInfoList class's DataPortal_Fetch, so all the data is retrieved in one database call. In your case this will require a join or a predictive load of the secondary entity - at least to be efficient.

Then the RiderInfo class will have a Child_Fetch method that accepts the entity object, not a data reader - at least that's the simple scenario assuming you don't care about having a pluggable DAL.

The Using CSLA 4: Data Access ebook walks through this process, but assumes a pluggable DAL. So in that book I convert the EF entities into either DTOs or a data reader - the idea being that entity objects aren't abstract enough to support different databases or mock data (though EF 4.1 now makes that pretty realistic with code-first entities).

So basically you need to decide if you want:

A non-pluggable DAL - in which case you can pass designer-generated entities into Child_Fetch

A pluggable DAL using a DTO or data reader interface like in the Data Access ebook

A pluggable DAL using the new code-first entity feature of EF 4.1

In each case though, the list does the query, and passes an entity, DTO, data reader, or code-first entity to the Child_Fetch method.

KevinManx replied on Thursday, April 28, 2011

Cheers Rocky. I was going around in circles on this and kept going off the wrong way. Implemented and now working.