by Marius Gheorghe
8. June 2007 16:43
Here's a "from the plane" overview of DataBlock's source code. This might help you to get started if you want to hack it : TableMetadata : this is the "central" type in the DataBlock world. It's the type from which the mapped objects inherit. A instance of this type contains both the data and also members that allow you to manipulate it's metadata. The most useful memebers are :
- TableFields[] : this property returns the array of DatabaseFields[] which map the database table fields. -TableName : the name of the database table - Relations : return the table's relations -Clone : shallow clone. Only the field's values are copied. -GetPrimaryKeyField L returns a reference to the OK field. -GetField(with overloads for field name and index): returns a reference to the specified field. -Attach/RemoveTableMetadata : attach/remove related objects.
PersistentObject : this type contains persistence methods and it's the base type for business objects.
Configuration: contains DataBlock configuration information. This data can be set at runtime and can be read directly from the config file by calling Configuration.ReadconfigData() at startup.
DataBlockException : exeception thrown by the PersistentObject operation which usually wraps database provider exceptions/
ExecutionEngine (resides in the ExecutionEngine) folder : this is the class which connects to the database and runs the queries. Note that the ExecutionEngine "works" in 2 modes : connected (by creating a instance of the type), this means that the database connection is opened for the lifetime of the instance and disconnected (by calling the static methods). In this mode of operation the connection is opended, the query runs and the connection is closed. Also in the same folder are a bunch of helper types like the "ConstaintManager" (creates query executino constraints), FK and PK constraints and the ExecEngine logger).
QueryCriteria : the query criteria is the API that allows you to query the database in a database independent and OOP way. The QueryCriteria type defines the supported operations while the IQueryCriteriaGenerator interface defines the operations that each dataabse provider must implement. The database implementations can be found in the QueryCriteriagenerators folder.
SqlGenerator : the big one. This one generates the SQL (note that this is database independent). The database providers must implement the ISqlGenerator interface which are called by the SqlGenerator for generating the database dependent pieces of the SQL query. another interesting type is the GraphBuilder which generates multiple SQL queries for sequential operations.
DataConvertor : contains conversion methods from and to all the supported types and data strctures.
DataFactory : factory type which initializes the ADO.NET types according to the settings.
Session : contains the DataBlock Session implementation.
This is a small introduction of the DataBlock types and their roles . I hope you'll find it helpfull if you'll try to understand / extend DataBlock. I'll post more detailed information soon.