ScanIAm wrote:I'm pretty sure you can build dataset-based objects from VS2003 by allowing the IDE to pull the structure from SQL. Isn't this the same thing?
dOOdads is a whole lot more than just an ORM framework -- it also provides:
+ ad-hoc creation of DB transactions in the IDE , without resorting to stored procedures
+ an intuitive and concise syntax for standard DB operations
+ methods that show the SQL that the framework generated for you
+ support for aggregate SQL operations
+ combined with a good OO language like C#, it includes easy ways to modify and extend the generated code. This helps you take the ORM "off the rails" if you need to -- as one of the posters above noted, DB structures don't often make good object structures, and I find myself building intermediate objects that are more sensible than what's generated.
The best way to demonstrate what's so nice about dOOdads is to look at some code:
// Adding a new record to multiple tables with transactional support
TransactionMgr tx = TransactionMgr.ThreadTransactionMgr();
try
{
Response.Write ("Beginning transactional database update. <br><br>");
Contentitems content = new Contentitems();
content.AddNew();
content.Con_Title = "This is a new test item for the UW";
content.Con_Subtitle = "New item";
content.Sta_StatusID = 1;
content.Save();
// Using the output parameter of our stored procedure, output the ID of the just-inserted record
int newContentID = content.Con_ContentID;
Response.Write ("Inserted new record to the database. ID: " + newContentID + "<br>");
// insert association on a second DB table
Contentitems_ContentitemsCategories conclass = new Contentitems_ContentitemsCategories();
conclass.AddNew();
conclass.Con_ContentID = newContentID;
conclass.Con_ConCatID = 27;
conclass.Save();
Response.Write("Inserted record to table Contentitems_ContentitemsCategories<br>");
tx.BeginTransaction();
tx.CommitTransaction();
Response.Write("Wrote transaction to DB<br>");
}
catch (Exception)
{
// In the case of an error, the entire transaction is rolled back.
tx.RollbackTransaction();
TransactionMgr.ThreadTransactionMgrReset();
Response.Write("rolled back transaction<br>");
}
// Example of how to load a business object by primary key
Contentitems myContent = new Contentitems();
myContent.LoadByPrimaryKey(11632);
//Example of how to test for null values in the DB
Response.Write("<BR><BR>");
bool IsItNull = (myContent.IsColumnNull("Con_TMPimage"));
Response.Write("Is it null?" + IsItNull);
// Using dOOdads to create a complex query without pain.
Even though this is a dynamic "WHERE" query, it enjoys the safety of being encapsulated in a stored procedure.
Contentitems mySelectContent = new Contentitems();
mySelectContent.Where.Con_Title.Value = "%UW%";
mySelectContent.Where.Con_Title.Operator = WhereParameter.Operand.Like;
// adding a tearOff parameter to the complex query
WhereParameter wp = mySelectContent.Where.TearOff.Con_Title;
wp.Operator = WhereParameter.Operand.IsNotNull;
mySelectContent.Query.AddResultColumn(Contentitems.ColumnNames.Con_ContentID);
mySelectContent.Query.AddResultColumn(Contentitems.ColumnNames.Con_Title);
mySelectContent.Query.AddResultColumn(Contentitems.ColumnNames.Con_Subtitle);
mySelectContent.Query.AddOrderBy(Contentitems.ColumnNames.Con_Title, WhereParameter.Dir.ASC);
mySelectContent.Query.Top = 100;
mySelectContent.Query.Load();
// programmatically populating a label, Label1, with a recordcount of mySelectContent
int TotalRows = (mySelectContent.RowCount);
Label1.Text = TotalRows.ToString();
// dOOdads' .LastQuery method exports the SQL statement that it automatically generated for you based on the params above
string myGeneratedQuery = mySelectContent.Query.LastQuery;
Label2.Text = "dOOdads generated the following query: " + myGeneratedQuery;
This ORM stuff blew me away when I first discovered it, and reminded me why I enjoy working with computers: with work and effort, you'll periodically discover methods that allow you to work many times faster and more effectively.
-KF