TypeDefs

Entity Developer for NHibernate provides the possibility to use custom type as a Type property value of model objects. If you use a certain custom type very often, it may be useful to define a shorter name for it. You can do this by defining a TypeDef in the model for your custom type. TypeDef assigns a name to a custom type, and can also contain a list of default parameter values if the type is parameterized. Even though NHibernate's rich range of built-in types and support for components means you will very rarely need to use a custom type, it is nevertheless considered good form to use custom types for (non-entity) classes that occur frequently in your application.

To edit the model TypeDefs list, do the following:

1.Select the model (root) node in the Model Explorer, or click on an empty diagram area to display the properties of the model.
2.In the Properties docking window find the TypeDefs parameter and click the three-dotted button next to it.

The following example illustrates how to create a TypeDef with the name 'MyCustomType' for a custom type with the full name 'CustomTypes.MyType, MyAssembly':

images_TypeDefsEditor

In case the type is parameterized, the list of default parameter values can be defined:

images_DefParamValuesEditor

After the TypeDef is declared, the short type name can be used for specifying the Type of model objects instead of specifying the full name of the custom type (e.g. for a property type):

images_TypeDefsTypeProperty

 


Send feedback on this topic

© 2008 - 2024 Devart. All rights reserved.