Frans,
I've gone through the DataAccessAdapter.FetchProjection method (which is fantastic BTW!) and I see that the List<IDataValueProjector> is only ever read... This is GOOD as I wish build some static fields to contain all my projectors as there is no point in buidling them over and over again.
However I never fully trust this kind of thing (things can change in the future) and ALWAYS create ReadOnly lists in order to ensure that we have thread safety.
When I build my ValueProjector list I want to save it as a ReadOnly list like:
internal sealed class ItemSummaryReader : ItemSummaryReaderBase
{
private static readonly IList<IDataValueProjector> _itemSummaryValueProjectorList;
static ItemSummaryReader()
{
_itemSummaryValueProjectorList = CreateItemSummaryValueProjectors().AsReadOnly();
}
private static IList<IDataValueProjector> CreateItemSummaryValueProjectors()
{
IList<IDataValueProjector> valueProjectors = new List<IDataValueProjector>();
valueProjectors.Add(new DataValueProjector(ItemSummaryFieldIndex.ItemID.ToString(), 0, typeof (long)));
valueProjectors.Add(new DataValueProjector(ItemSummaryFieldIndex.FileUID.ToString(), 1, typeof (Guid)));
valueProjectors.Add(new DataValueProjector(ItemSummaryFieldIndex.FileSystemID.ToString(), 2, typeof (short)));
...
}
}
But this would require the FetchProjection API to support IList<> rather than List<>. Do you think this is something you might consider?
public void FetchProjection( IList<IDataValueProjector> valueProjectors, IGeneralDataProjector projector, IDataReader reader )
Marcus