Posted in July 9, 2009 ¬ 7:00 amh.Chris Richards
DBObject has come a long way recently and there is a lot of duplicated code. So I think now is a good time to refactor. Let’s start with the most obvious items. There are only 11 methods in the DBObject, 7 of them take string connection, 4 take string index_column, and another 4 take string [...]
Read the rest of this entry »
Posted in July 8, 2009 ¬ 9:18 amh.Chris Richards
Last time I said it would be nice to know if the record already exists in the database. When you want a one-to-many relationship, you don’t want to accidentally add the same record more than once. If an object is made that has the exact same values as another record, we shouldn’t add it, but [...]
Read the rest of this entry »
Posted in July 7, 2009 ¬ 9:04 amh.Chris Richards
I’ve added self updating and Insert to the DBObject. I’ve also changed the naming of the columns it pulls from the database. Each column property now starts with “column_”.
Read the rest of this entry »
Posted in June 19, 2009 ¬ 4:36 pmh.Chris Richards
Recently someone found my blog by searching google asking how to get the column name from a MySqlDataReader. I doubt they found the answer on my blog, so I figured I’d write about, just in case anyone else needs to know.
Read the rest of this entry »
Posted in June 11, 2009 ¬ 10:19 amh.Chris Richards
Looking into other ORMs and Linq I came across subsonic. I watched the video and build a quick little sample application with it. I had a slight problem at first because it kept giving me an error with my MySql.Data reference. I upgraded my DLL and played around with it some more, still no luck. [...]
Read the rest of this entry »
Posted in May 29, 2009 ¬ 8:32 amh.Chris Richards
I created the GetProperty() and SetProperty() methods to allow the base object to manage holding the variables needed for the object. I’ve implemented these methods on my old object classes just to test them out in some real world examples. I’ve found two problems, the first is that sometimes I only want to set a [...]
Read the rest of this entry »
Posted in April 15, 2009 ¬ 1:43 pmh.admin
I have the join working but it’s not pretty. _tags = DBObject.WhereJoin(“user_id”, “=”, this.ID, typeof(DBTag), “tag_user”, “tag_id”, “id”, DBUser._conn); Right now, in the Where you have to specify all the information about the Join, the table, the columns, etc. and it doesn’t use a property but the column name (because there is no object for [...]
Read the rest of this entry »
Posted in March 4, 2009 ¬ 4:10 pmh.Chris Richards
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, [...]
Read the rest of this entry »
Posted in March 2, 2009 ¬ 4:51 pmh.Chris Richards
Ok it works. I also created a checker for the opertators so we don’t get invalid/malicious code. /// /// Returns a DBList of objects that match the Where /// /// Property to Match /// “=”, “<”, “>”, “LIKE” /// Value to Match /// Type of the object to get (Must inherent from DBOBject) /// Connection [...]
Read the rest of this entry »
Posted in February 25, 2009 ¬ 4:39 pmh.Chris Richards
Alright, now I have a working .By It actually simplifies things a lot, to the point I’m starting to double think making everything static. As you can see, you can simply call something like: DBUser chris = (DBUser)DBObject.By(“firstname”, “chris”, typeof(DBUser), Utility.connMy); DBUser bob = (DBUser)DBObject.By(“id”, “1327″, typeof(DBUser), Utility.connMy); And get back a valid user. This [...]
Read the rest of this entry »