>I can not create a Conditional as a CASE, IF or similar because, YES, I have 600 different objects, each table of my system represents a new object.
>
>So I will have something like this:
>
>Webpage1
>RegionCollection myregioncollection = new RegionCollection().Load();
>. . . //more code
>Webpage2
>EmployeeCollection myregioncollection = new employeCollection().Load();
>
>Other webpage to N
>AuthorCollection myregioncollection = new AuthorCollection().Load();
>
>
>So, you could have as many objects as you pages you need to perform CRUD operations.
>
>
>Now to make life easier, I am creating a web control that allows to navigate through the data (move first, move last, delete, new, etc).
>
>
>I need to recover the object from the session in the web control:
>
>
>Xtype myLOCALcollection;
>myLOCALcollection = (Xtype) Session["coleccion"];
>
>
>Here you can see my trouble, I don’t know at compile time, what is the type of the local collection, say, the current collection.
>
>In few words, I need to create the type Xtype at run-time and BASED on the type of the object that is saved into the session var.
Hi, Victor.
As I said, I guess it is a design problem. What do you want to do with the objects in the collection? If what you need is to perform CRUD operations, then your objects should all implement a common interface like: IPersistent or something like that (with New, Save and Delete operations, for example:
In this case, when you loop through your collection you use:
for each ( IPeristent entity in yourCollection )
entity.Save();
Do you understand the general idea? Of course this could be safer using generics, but it works like that with your code.
Regards,