Awesome. I've been using Generics in some coding in ASP.NET 2.0. Again, Awesome! But I am having some trouble understanding another aspect, related to the Data Access Layer.
I am attempting to re-create the Data Provider model that Issue Tracker uses, in my ASP.NET 2.0 application. I am using the abstract pass-through methods in the Data Access Layer class, and using a delegate from that class to generate collections from within the individual data classes (i.e. SqlDataAccessLayer, AccessDataAccessLayer, etc.).
My question becomes, what is the best way to implement generics in this process, over the strong typed collections.
Assuming this is for a category, I have done this, and would like to know if I am going about it incorrectly.
sample from DataAccessLayer.cs
-------------------------------------------------------------------------------------
protected
delegate IList GenerateCollectionFromReader(IDataReader returnedCollection);
protected List<Category> GenerateCategoryCollectionFromReader(IDataReader returnData)
{
List<Category> TempCollection = new List<Category>();
while(returnData.Read())
{
Category TempCategory = new Category(Convert.ToInt16(returnData["Id"]),
Convert.ToString(returnData["Title"]))
TempCollection.Add(TempCategory);
}
return TempCollection;
}
------------------------------------------------------------------------------------
Am I right in assuming that when the delegate's return type is of IList, I am forcing the compiler to do type conversions?
Any suggestions would be greatly appreciated. Thanks.