"pali" <pa**@discussio ns.microsoft.co m> a écrit dans le message de news:
50************* *************** **...icrosof t.com...
| Yes, i know this is the limitation, I'm asking why? Is that a by-design
choice?
I guess so, Delphi has virtual static methods.
| I don't think it's meaningful to instantiate an instance of an object only
| to be able to read/delete it from the store.
| My typical class would look like this:
| public class Customer : EntityBase
| {
| public static Customer GetByID(int id) {}
| public void Save() {}
| public static void Delete(int id) {}
| }
| In this case i don't see a reason to instantiate an object if I want to
get
| it from the database by id anyway. Same for the delete, I don't want to
have
| to get an entity from the database just to be able to delete it.
| I want to put the signatures of those methods in the parent abstract
class,
| so I can get/save/delete them in a generic way...
Then how about factoring out the retrieval behaviour, which I would say
doesn't belong in the Customer class and use an Object Persistence Framework
instead ?
If you are using .NET 2.0, you can have methods on it like :
public class ObjectStore
{
public objectT RetrieveObject< objectT>(int Id)
{
...
}
...
}
Although I would also argue that most times you could retrieve a browsing
list for a criteria and then choose one object. That way you don't need to
know the ID outside of the OPF.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer