Encapsulated invocation sample for csla 4 doesn't use SafeDatareader

Encapsulated invocation sample for csla 4 doesn't use SafeDatareader

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


OscarLauroba posted on Tuesday, February 15, 2011

I'm studying the encapsulatedInvoke sample recently released and I've found that child_fecth of PersonInfo uses idatareader instead of SafeDatareader. Shouldn't it be better if the Fetch function of the interface IPersonDal returned a Safedatareader?

RockfordLhotka replied on Tuesday, February 15, 2011

The purpose of the sample is to illustrate a very abstract DAL implementation that doesn't rely on any specific type of data reader.

SafeDataReader is a nice tool for removing null values, but it is absolutely not required for any application scenario.

OscarLauroba replied on Wednesday, February 16, 2011

Thank you Mr.Rockford for taking the time for response.

So, How should I use SafeDatareader in this Encapsulated invocation model? I'm migrating my code from Encapsulated implementation to Encapsulated invocation and I would like not losing the funcionality that Safedatareader provides.

RockfordLhotka replied on Wednesday, February 16, 2011

I discuss how to use SafeDataReader in the Data Access ebook. It wraps any IDataReader. So in that example, you might do this:

var data = new SafeDataReader(dal.Fetch());

Because the Fetch method returns an IDataReader, the result can be wrapped in a SafeDataReader to eliminate null values.

Copyright (c) Marimer LLC