| DataObjects for .NET (Enterprise Edition) > Application Configurations > Data Library > Creating a Data Library Project |
Data library projects are created using the C1DataObjects Data Project Wizard. Select File | New Project in the Visual Studio menu, and in the New Project dialog box, under Project types, choose either Visual Basic or Visual C#, according to your language preference and select ComponentOne Data Library in the right pane.
The main file of the resulting data library project is a component class hosting the schema and business logic. The schema is stored in the C1SchemaDef component. To edit the schema, use the Schema Designer; for more information, see Schema Objects. To open the designer, select Schema Designer from the C1SchemaDef component's context menu.
To attach business logic code to a schema object (table or table view) use business logic components. Business logic components (components C1TableLogic and C1DataSetLogic) have events in which you can write code responding to various occurrences in data objects. Business logic components reside on the same design surface (component class) with the C1SchemaDef component (in large projects, it is also possible to distribute business logic code over multiple files). Only one business logic component is allowed for each schema object: a single (or none) C1TableLogic component for each table and a single (or none) C1DataSetLogic component for each data set in the schema.
To create business logic components, right-click the C1SchemaDef component and select Create Business Logic Componentsfrom the context menu that appears. This will create a business logic component for each table and each data set in the schema. Alternatively, you can create business logic components manually, from the Toolbox, but in that case you need to set their properties: SchemaComponent = schemaDef to connect them to the schema component, as well as Table and DataSetDef to specify which schema object each of them represents.
In large data library projects, it may be desirable to use multiple source code files to write business logic code. It can be done using a special C1SchemaRef component. A C1SchemaRef component's only purpose is to represent the C1SchemaDef component holding the library's schema when it resides in a different file in the project. Add a new component class file to the project, put a C1SchemaRef component on the design surface and connect it to the C1SchemaDef component selecting its name in the SchemaDef property combo box. Note that working with multiple files using C1SchemaRef, the file with the C1SchemaDef component must be open. Once a C1SchemaRef component is set up, you can add business logic components, C1TableLogic and C1DataSetLogic to the component class file, dropping them from the Toolbox. For each business logic component, set its SchemaComponent property to the C1SchemaDef component and select the table (Table) or the data set (DataSetDef) represented by the business logic component.
You can attach event code to business logic components either by selecting the components on the designer surface, or using the Business Logic Events tool window (select Business Logic Events from the C1SchemaDef or C1SchemaRef context menu to open the tool window). The Business Logic Events tool window shows the list of all tables and data sets. When you select a table in the tool window, the table's business logic events appear in the Properties window (in Visual C#, when the Events radio button is selected in the Properties window; in Visual Basic use the Method Name combo box in the code editor).