Advantages of Typed DataTables
Jump to navigation
Jump to search
Overview
OpenPetra's Typed DataTables provide many advantages over normal, untyped DataTables.
The resulting source code that defines the resulting Typed DataTables is automatically created by a generator (invoked by 'nant generateORM
').
List of Advantages of Typed DataTables
- Typed DataColumns (e.g.
Int32
,string
,DateTime
, ...) instead of everything just being of Typeobject
.- Relieves the developer from casting all the time. Casting is annoying for the developer and error-prone, and one only finds out at run-time whether the cast to a certain type is correct as one side of the cast is always of Type
object
and therefore will accept anything at compile-time. - Provides compile-time checks for the correct Type when reading data from/writing data to DataColumns.
- Relieves the developer from casting all the time. Casting is annoying for the developer and error-prone, and one only finds out at run-time whether the cast to a certain type is correct as one side of the cast is always of Type
- Easier referencing of DataColumns:
MyTable.MyColumn
instead ofMyTable.Columns['MyColumn']
- When using the
MyTable.MyColumn
notation: compile-time checks are done if DataColumns are existent/spelled correctly. - When using the
MyTable.MyColumn
notation: The IDE offers Code Completion and shows ToolTips about the Type of a DataColumn when the mouse cursor is 'hovering' over a DataColum name. - When using the
MyTable.MyColumn
notation: Performance increase - the lookup of the Index of the DataColumn is done only once, whereas with a normal DataTable it is done everytime a DataColumn is accessed by name.
- When using the