Tuesday, March 09, 2010
Inserts and Updates
Minimize

EasyObjects.NET uses a DataTable internally to store your data, which provides a wealth of built-in features, some of which have already been covered in other tutorials.
  1. True support for NULL values, rather than using some "placeholder" value to represent a NULL (i.e. a common hack for this is to use zero (0) for int columns, DateTime.MinValue for datetime columns, and so on). Using a placeholder means that the value now has two meanings, and removes the ability to use the placeholder value for it's actual meaning. Note: EasyObject's support for NULL values is not the same as Generics, which will not be supported until .NET 2.0.
  2. Maintain the state of each DataRow in the DataTable using DataRowState. This allows the developer to perform Inserts, Updates and Deletes in memory and "batch" them all to the server in one transaction.
  3. Serialization/deserialization of the schema and data to XML.
  4. DataBinding operations via the DefaultView.
  5. Filtering data using the DefaultView.RowFilter.
  6. Iteration through all the rows via DataRowView enumerator.


IsColumnNull and SetColumnNull
  1. IsColumnNull allows for testing if a column contains a NULL before attempting to retrieve the column into a value type that cannot hold a NULL (for example, an integer or a DateTime).
  2. SetColumnNull allows for placing a NULL value into the DataTable for a column.
  3. Here's an example of both methods in an "s_" property from a generated EasyObject:

The Save method

  1. Performs a batch update of all changed data in the internal DataTable. New rows are inserted, changed rows are updated and deleted rows are removed.
  2. Auto-increment columns, computed columns and timestamps are automatically available immediately after the Save().
  3. All operations are performed on the same connection and within the same transaction.

MarkAsDeleted and DeleteAll

  1. Used to mark the current row in the DataTable as deleted.
  2. DeleteAll will mark all rows as deleted.
  3. The data is not actually deleted from the database until Save is called. 

ToXml and FromXml
  1. ToXml is used to convert the internal DataTable contents to an XML string.
  2. FromXml is used to reconstitute the EasyObject data from an XML string, usually from a call to ToXml.
Last updated: 01/23/2007

Syndicate  Print  

Privacy Statement  |  Terms Of Use
© 2007 Noonan Consulting Inc.