Using Attributes

This topic applies to .NET version only

.NET Attributes provide the means for a developer to add meta-data that describes, or annotates specific elements of code such as classes, methods, properties, etc. At compile time the resulting metadata is placed into the Portable Executable (PE)file along with the Microsoft Intermediate Language (MSIL). Once metadata is in the PE other .NET programs may access it using the .NET Reflection API.

Attributes can be used to document classes at design time, specify runtime information (such as the name of an XML field to be used when serializing information from the class), and even dictate runtime behavior (such as whether the class should automatically participate in a transaction).

You can use attributes with db4o to configure how db4o will process your classes. At present we provide only one attribute:

[Indexed]

This attribute can be applied to class fields


and its functionality is equivalent to the db4o configuration setting:

Db4o.Configure().ObjectClass(clazz).ObjectField("fieldName").Indexed(true)