This short example demonstrates how to use the storage in your code.
| C# VB.NET |
// Create the instance of the Oracle storage. Oracle storage = new Oracle("user", "password", "host"); // Set it as storage of the ObjectContext. ObjectContext context = new ObjectContext(storage); ' Create the instance of the Oracle storage. Dim storage As New Oracle("user", "password", "host") ' Set it as storage of the ObjectContext. Dim context As New ObjectContext(storage) |
| C# VB.NET |
// Specifies the sequence in care of the autoincrement // values. This sequence must be defined in the database. // {0} stands for the name of the entity. // {1} stands for the name of the field. storage.SequenceFormat = "{0}_{1}_SEQUENCE"; ' Specifies the sequence in care of the autoincrement ' values. This sequence must be defined in the database. ' {0} stands for the name of the entity. ' {1} stands for the name of the field. storage.SequenceFormat = "{0}_{1}_SEQUENCE" |
The format should be specified immediately after the instance of the storage class is created.
{0} stands for the name of the entity for which this sequence is generated.
You may also add {1} which is then the name of the field for which the sequence is created.
When specifying the sequence format as "{0}_{1}_SEQUENCE" for a persistent class mapped to the NEWS entity and the autoincrement field with name ID you need to generate the following sequence in the database: NEWS_ID_SEQUENCE. The sequence format needs only to be specified once. You need to create for each persistent object type with an AutoNumber a sequence (fulfilling the specified format) in the database.