Wednesday, March 4, 2009

helpers

I which I could put this in the base class somehow, but we can simplify the code if the inherited class override the By and Where methods like so


///
/// Get a single User By the property and value specified
///

///
///
///
static public DBUser By(string property, object value)
{
return (DBUser)DBObject.By(property, value, typeof(DBUser), DBUser._conn);
}

///
/// Returns DBList where all the DBUsers have a matching property
///

///
///
///
///
static public DBList Where(string property, string evaluator, object value)
{
return DBObject.Where(property, evaluator, value, typeof(DBUser), DBUser._conn);
}


Then we can make simple calls like:

DBUser u3 = DBUser.By("firstname", "chris");
//and
DBList users1 = DBUser.Where("id", "<=", 1313);

No comments: