My question is probably not well formulated, and it is probably a hoax, but here I go
class person {
protected static string request = "select * from person where gender in ('male','female')";
public string sharedmethod()
{
return "the request is" + request;
}
}
class man:person
{
override protected static string request = "select person.*,man.* from person,men where mytype in ('male') ";
DateTime dateOfFirstCar;
}
class woman:person
{
override protected static string request = "select person.*,woman.* from person,women where mytype in ('female') ";
DateTime dateOfFirstITBAG;
}
class Program
{
static void Main(string[] args)
{
if (new person().sharedmethod() == new man().sharedmethod())
Console.Write("too bad query is the same in base and dervide class");
}
}
Man - man Woman - man
Man, man, woman is in my database, but different requests are needed.
I do not want to duplicate these requests, so I thought it would be nice to store them in a static property in each class.
I got some low-level stuff (not figured there) that lies in the base class (coz, which I don't want to duplicate), and I wanted the inherited classes to call the base class method with the context of the allocated classes
. [inherited] somemethod() person.somemethod(), ,