Thanks for the response.
My Worker (WorkerInfo) object is one of many different entity types in my
solution. Another one is a Customer (CustomerInfo) object.
Therefore, my Interface cannot be specific to any one of these. I think I
can create an interface that contains a reference to each of my different
object types, such as IentityInfo.
IEntityInfo would then be reference in my DAL function, such as:
Public List<Type> TransformReader(String type) where Type: IEntityInfo
However, my Reader is specific to one of these object types. What I'm
trying to avoid is a long switch statement, such as:
Switch(type){
Case "Worker":
//Create new instance of List<WorkerInfo>
//Fetch Reader.rows
//For each row, create new instance of WorkerInfo
//place contents of row.fields into WorkerInfo.properties
//Return List<WorkerInfo>
Case "Customer":
//Same process for CustomerInfo
}
At this point, I can't see a way around this Switch statement. However,
using the Interface should keep my solution down to only one function,
instead of needing one for each entity type.
Thanks
_____
From: StrongTypes@yahoogroups.com [mailto:StrongTypes@yahoogroups.com] On
Behalf Of santiago.perez@...
Sent: Wednesday, June 07, 2006 2:36 PM
To: StrongTypes@yahoogroups.com
Subject: Re: [StrongTypes] DAL - ; how-to use List<> collection obj. w/o
reference to specific t
Not sure I follow 100% but it seems to me that you want your function to
accept a parameter with a specific signature hence an Interface. If you're
worker objects implement the interface you can pass in any of your worker
objects to this function. Then when you define your list instead of doing
this:
Public List<Type> TransformReader(String type, etc..)
DO something like this:
Public List<Type> where Type : IWorker
Santiago Perez
Florida's Turnpike Enterprise
Programmer Analyst
Pompano Operations
Ph 954-975-4855 ex 1127
Cell 954-444-9429
"kmiller_work"
<kirknmiller@veri
zon.net> To
Sent by: StrongTypes@ <mailto:StrongTypes%40yahoogroups.com> yahoogroups.com
StrongTypes@yahoo cc
groups.com
Subject
[StrongTypes] DAL - ; how-to use
06/06/2006 07:19 List<> collection obj. w/o
PM reference to specific t
Please respond to
StrongTypes@yahoo
groups.com
Here's my scenario:
1. I have a DAL
2. In my DAL, I want ONE function that will transform an ADOReader
resultset into a strong data entity object that I will call an Info
entity (e.g. WorkerInfo). My info entity contains only properties,
and each field of each row of my Reader will provide the content for
the property attributes of my object.
3. I can do this easily for each of my different data entities, but
I don't want to have to create a new function for each of them.
Instead, I would like to pass to my function what Type of entity is
getting filled, as well as my params and proc name needed to fill
the ADOReader.
4. Here's an example of what I'm doing:
Public List<WorkerInfo> TransformReader(string type, string[]
params, string proc)
{
//Create a new List<> obj
List<WorkerInfo> myCollection = new List<WorkerInfo>;
// fetch Reader from DB
// Loop thru each Reader.row
// For each row, create a new WorkerInfo entity
WorkerInfo wInfo = new WorkerInfo();
//Loop thru each field in the Reader.row and set the
WorkerInfo.properties to the value of each field
// Add the new WorkerInfo entity to the
myCollection.add(wInfo);
//Pass out of function the List
return myCollection;
5. My question for the board is, HOW can I base class this function
so that I don't have to build one for each of my different Data
Entity objects (WorkerInfo)?
I've tried doing something like the following, but I get errors:
Public List<Type> TransformReader(String type, etc..)
.. but the compiler doesn't allow me to do this... the List WANTS to
know what Type I'm dealing with.
Thanks
[Non-text portions of this message have been removed]