|Applies To:||DataObjects for .NET|
ComponentOne DataObjects for .NET (C1DataObjects) is based on Microsoft ADO.NET technology and enhances it in many significant ways to streamline database application development. C1DataObjects follows the standard business object paradigm, enabling developers to write business logic components called data libraries, which can be reused in multiple projects. This provides a clear separation of the business logic from the presentation layer, or GUI. Another advantage of this architecture is that data libraries can be used in both WinForms and WebForms applications.
C1DataObjects also provides an innnovative virtual mode technology that makes it ideal for working with large datasets in WinForms applications. In fact, since ADO.NET cannot handle large datasets, using C1DataObjects is the only way to overcome this limitation.
C1DataObjects completely automates the development of distributed 3-tier web-based applications, freeing developers from the task of writing special server-based code. For even greater control over application performance, ComponentOne WebDataObjects for ASP.NET encapsulates the functionality of C1DataObjects and provides optimizations for server-side caching and object pooling.
The easiest way to get started with C1DataObjects is to connect to an OLE DB data source and import its structure into a data schema, which is represented by a C1SchemaDef component on the form. This component provides access to the Schema Designer, which is used to specify the tables and fields that are exposed to bound controls and other data consumers. The Schema Designer's Import Wizard prompts for a connection string and login credentials, then displays the tables, views, and aliases available for import.
The Schema Designer displays a graphical view of the underlying database structure and the datasets that are exposed to consumers. It contains the following windows:
|Tables||A list of available database tables, both simple and composite. A simple table is a physical database table. A composite table represents two or more related tables, which can be any combination of simple and composite. From the perspective of the data consumer, there is no difference between simple and composite tables.|
|Relations||A list of relations between pairs of tables based on foreign key constraints stored in the database. Relations can also be defined manually in the Schema Designer.|
|Connections||A list of database connections. Most schemas have only one connection.|
|DB Tables||A list of physical database tables for the active connection.|
|DataSets||A list of one or more named datasets that define a set of table views.|
|Schema Graph||A graphical representation of database tables, field names, and inter-table relationships.|
|Property Browser||A .NET-style property grid that can be used to examine and customize the attributes of tables, fields, relationships, and other schema objects.|
|Output||A results window for schema verification and error reporting.|
The following figure shows the user interface of the Schema Designer. Initially, the tab control in the middle of the main window contains only the Schema Graph.
Double-clicking an item in one of the tool windows, such as DataSets or Relations, opens the item for editing by creating a new tab for it in the middle of the main window.
Each data schema must contain at least one dataset, which is a collection of tables and relationships as they are exposed to data consumers. Typically, a dataset exposes a subset of the available tables in the underlying data source. The C1DataSet component represents a dataset and serves as a data source for bound controls.
The following C1DataSet properties are used to associate the component with a data schema:
|SchemaDef||The name of a C1SchemaDef component on the form.|
|DataSetDef||The name of a dataset defined in the Schema Designer.|
The following properties are used to associate a bound control with a C1DataSet component:
|DataSource||The name of a C1DataSet component on the form.|
|DataMember||The name of a table view defined in the Schema Designer.|
One of the key features of C1DataObjects is the ability to combine multiple tables in a single aggregate that is exposed to data consumers as a simple table. Composite tables are similar to database views formed by an SQL statement with joins. However, with C1DataObjects, developers can specify tables and relationships using database diagrams in the Schema Designer without writing SQL.
Within the Schema Graph window, each simple table is represented by a child window containing a list of field names with check boxes. Only the checked fields will be exposed to data consumers. Developers also have control over the default field name order in the composite table, and can designate individual fields as read-only.
When an application attempts to modify a row in a composite table, C1DataObjects automatically collects all modified simple table rows and sends them to the server for updating.
By defining view relations between tables in the Schema Editor, developers can implement master-detail relationships between bound controls without coding. If view relations are defined, the DataMember property of bound controls will display additional nodes representing the parent/child portions of the relation. At run time, the detail control automatically responds to row currency changes in the master control.
C1DataObjects supports the creation of calculated fields based on expressions that involve other database fields. To the data consumer, calculated fields are indistinguishable from native database fields.
A constraint expression can be used to specify the range of legal values when a database field is being updated. By placing such constraints within the data schema, business logic can be centralized and maintained in a single location.
At run time, invalid data entry results in the display of the specified error message.
The recommended way to use C1DataObjects is to create a data library project that defines a single schema, then reuse the data library in multiple projects. Note that both WinForms and WebForms projects can share the same data library.
To consume a data library in another project, the developer adds a reference to the data library assembly, then sets the DataLibrary property of the C1DataSet component(s) to the filename of the assembly, excluding the .DLL extension. In this scenario, the SchemaDef property is not used since the C1SchemaDef component resides in the data library itself.
C1DataObjects offers many other features not described in this article, including:
- Virtual mode technology for binding to large datasets in WinForms applications.
- Programmable business logic components for customizing the behavior of datasets and table views.
- SQL-based tables for supporting nonstandard SQL and stored procedures.
- Unbound tables for non-SQL data sources populated in event handlers.
C1DataObjects is part of ComponentOne Studio for WinForms. To download an evaluation version, please visit the link below.