Ok, so I'm trying to make a nice superclass for data-access objects that can generate a tsql query to search all of the subclass's public string properties. I want to use reflection to get the type of the subclass and then iterate through all of the public string properties on the object, since those property names are the same as the database column names. Then I can use those property names to generate a tsql query.
[caveat: hey, id rather use nhibernate but no way I could convince these guys to use that]
[Also I could solve this with generics, but I think they find generics scary because they are VB.net guys, (sorry if I hurt your feelings VB.net peeps ;( )]
Ok so the base object is something like this:
public abstract class RepositoryBase
{
public static IList<RepositoryBase> Search()
{
//get all public properties of the inheriting subclass
// I already have the rest of the search code
}
}
Is this even possible, or advisable?
While I was typing this, I was like "screw it, I'll just do it with generics".
Thanks for reading!