Oracle Custom Class Wizard

Using the Oracle Custom Class Wizard, you can generate .NET custom classes for both object types and collection types. These classes can be used to build ODP.NET applications that work with UDTs in Oracle Database.

The Oracle Custom Class Wizard enables you to generate .NET custom classes in one of the following languages: C#, VB.NET, and Managed C.

The wizard allows you to configure some properties of the custom class.

This section covers the following topics:

Starting the Oracle Custom Class Wizard

To start the Oracle Custom Class Wizard, do the following:

Select the Generate Custom Class item from the menu of an object type or collection type node.

Oracle Custom Class Wizard does not start unless a project is open. If there is a solution without a project, it cannot start.

The opening screen of the Oracle Custom Class Wizard appears as follows:

Using the Oracle Custom Class Wizard

The Oracle Custom Class Wizard gives you the ability to control certain details about the custom class.

Languages in the Oracle Custom Class Wizard

The wizard detects which language the project is in and generates code in that language.

If there is more than one open project from different languages in the solution, then the project that the wizard generates is determined using the following order:

  1. The first C# project found.

  2. The first Visual Basic project found.

  3. The first managed C project found.

See Also

Generating Classes with the Oracle Custom Class Wizard

Generating Classes with the Oracle Custom Class Wizard

The Oracle Custom Class Wizard has two primary screens that enable you to customize the generation of code.

The first window enables you to choose types and configure code generation details as follows.

The second window enables you to customize the attributes for the types you have chosen in the first window.

This wizard automatically generates default names for the following based on the related information from the selected user-defined type:

  • File name

  • Project

  • Namespace

  • Class name

  • Super class Name

  • Property Name

All of the auto-generated names will be in mixed case.

The Oracle Custom Class Wizard provides the following windows to generate custom classes corresponding to UDTs of both collection type and object type:

Window Description

Welcome to the Oracle Custom Class Wizard

Welcome page for the wizard. To bypass this page the next time you run the wizard, select the Do not show this page again check box. See "Starting the Oracle Custom Class Wizard".

Choose Types and Configure Code Generation Details

A tree view appears on the left side of the wizard as follows:

  • For a collection type with an element type of UDT, the tree view shows the base type of the element and below that, the element type. Then it shows the collection type node, in a separate hierarchy, at the same level as the base type of the element.

  • For an Object Type, the tree view shows the base types in a hierarchical manner.

Select the desired user-defined type. See "Using the Oracle Custom Class Wizard"

Next is disabled if no UDTs are selected.

Specify the following information:

  • File name: The file in which the custom class is generated. Default value is name of UDT, with an extension of .cs, .vb, or .cpp based on the type of project you have selected, in the following manner: If UDT is PERSON_TYPE, then the file name is Person_Type.xx.

  • Project: A list of projects which are loaded in the solution. Each class can be generated in different projects, which you can select from the list.

  • Inherit from Project: If this is checked, then the namespace is derived from the Project name and the Namespace field is read-only. Inherit from Project is checked by default.

    The field is disabled if the project selected is of type VB.NET.

  • Namespace: The namespace that the class is added to. Default is the name of the project namespace, which is derived from the Project name. You can change this name by deselecting Inherit from Project.

    For VB.NET projects, the custom class is not generated in a separate namespace, but in the default project namespace. The field is disabled if the project selected is of type VB.NET.

  • Class name: The name of the class. Default is name of UDT.

  • Super class name: For Object Types Only:

    The super class, if you wish to indicate one. If provided, the class you generate derives from the super class entered here. This must be a fully qualified class name with namespace. The default is taken from ObjectType.SuperClass as defined in the database. If the type does not define a super type, then this field is disabled.

Customize Attributes

In this window the type (object type or collection type), such as ABS_PERSONAL_TYPE that you selected in the previous screen appears in the left side.

The right window displays properties of that type in a read-only mode. These properties are still available by clicking Back. The properties include Filename, Project, Namespace, Class Name, and Superclass Name.

Click Next to view the second part of this window. Next is disabled if no UDTs and attributes are selected.

The same tree view appears, but the right side contains the properties of the attributes (for object types) and elements (for collection types). When you highlight an attribute or element in the tree view, its properties appear on the right side as follows:

  • Property Name: The name of property that is tied to the attribute. Default value is name of attribute, in title case. For example, if the attribute name is IDNO, the property name is Idno.

  • Database Type: The type of attribute in the database. Read-only.

  • .NET Data Type: The .NET data type that corresponds to the SQL type. You can select from the list of types that are applicable in the context of the SQL type and override the default .NET Types. In case an attribute is itself of type UDT, the .NET Data Type field is blank and read-only. This list also contains Oracle specific types supported by ODP.NET such as OracleBLOB, OracleBFile, and so on, so that properties can map directly to these types.

  • Class Name: Applicable only for attributes of type UDT. Otherwise, this is read-only and blank. For attributes of type UDT, this field is automatically filled with the class name, which is the name of the UDT type in title case. Users can change this name to a class that corresponds to the user-defined type of the attribute that has already been generated or will be generated later.

  • Property Access: The access modifier for the property. Valid values available in the list are public, private, internal, and protected. Default is public, however users can change this value.

If either the Class Name or Property Name field is empty, then the wizard displays an error message.

Summary

Displays a summary of the different tasks to be performed to generate the .NET custom class, if the required information is provided. The Summary indicates the project that the class will be added to and the file that will contain the class definition.

This window indicates that the class will not be generated if a UDT Type was de-selected, either in the Configure Class details screen or in the Customize Attributes screen.

Click Finish to complete the wizard tasks or Back to change or add information.

During code generation, for each of the files being generated, if a file with a name you provided already exists, you are prompted to overwrite that file as follows:

  • If you select Yes, then the file is overwritten and processing continues.

  • If you select No, then the corresponding files are not created or not overwritten and the wizard remains open, allowing you to rename or overwrite the existing file.

For the selected project, the wizard adds reference to Oracle.DataAccess.dll (ODP.NET). If the reference already exists, then it is not overridden, but a message displays in the Output Window indicating that the reference was not added. You must have the correct version of ODP.NET in the references section.

When the process completes, the wizard closes and all newly created files are opened for editing. The output window also lists the success or failure of code generation.