PersisterFactory() Constructor
Class
InterSystems.XEP.EventPersister is the main entry point for the XEP module. It provides methods that can be used to set XEP options up, establish an XEP connection, import schema, and produce XEP Event objects. It also provides methods to control transactions and perform other tasks.
EventPersister.
Connect() connects to Caché using either an eXTreme connection or a TCP/IP connection, depending on the arguments specified. If only
namespace,
username, and
password arguments are specified, an in-process eXTreme connection is established. If
host and
port are also specified, a TCP/IP connection is established.
void Connect(string nmspace, string username, string password)
void Connect(string host, int port, string nmspace, string username, string password)
-
nmspace namespace to be accessed.
-
username username for this connection.
-
password password for this connection.
-
host host address for TCP/IP connection.
-
port port number for TCP/IP connection.
EventPersister.
GetEvent() returns an
Event object that corresponds to the class name supplied, and optionally specifies the indexing mode to be used.
Event GetEvent(string className)
Event GetEvent(string className, int indexMode)
-
className class name of the object to be returned.
-
The following
indexMode options are available:
-
-
-
Event.INDEX_MODE_SYNC indexing will be performed each time the extent is changed, which can be inefficient for large numbers of transactions. This index mode must be specified if the class has a user-assigned IdKey.
The same instance of
Event can be used to store or retrieve all instances of a class, so a process should only call the
GetEvent() method once per class. Avoid instantiating multiple
Event objects for a single class, since this can affect performance and may cause memory leaks.
string[] ImportSchema(string classOrDLLName)
string[] ImportSchema(string[] classes)
-
classes an array containing the names of the classes to be imported.
-
classOrDLLName a class name or the name of a
.dll file containing the classes to be imported. If a
.dll file is specified, all classes in the file will be imported.
If the argument is a class name, the corresponding class and any dependencies will be imported. If the argument is a
.dll file, all classes in the file and any dependencies will be imported. If such schema already exists, and it appears to be in sync with the .NET schema, import will be skipped. Should a schema already exist, but it appears different, a check will be performed to see if there is any data. If there is no data, a new schema will be generated. If there is existing data, an exception will be thrown.
string[] ImportSchemaFull(string classOrDLLName)
string[] ImportSchemaFull(string[] classes)
-
classes an array containing the names of the classes to be imported.
-
classOrDLLName a class name or the name of a
.dll file containing the classes to be imported. If a
.dll file is specified, all classes in the file will be imported.
If the argument is a class name, the corresponding class and any dependencies will be imported. If the argument is a
.dll file, all classes in the file and any dependencies will be imported. If such schema already exists, and it appears to be in sync with the .NET schema, import will be skipped. Should a schema already exist, but it appears different, a check will be performed to see if there is any data. If there is no data, a new schema will be generated. If there is existing data, an exception will be thrown.
EventPersister.
Rollback() rolls back the specified number of levels of transaction, where
level is a positive integer, or roll back all levels of transaction if no level is specified.
void Rollback()
void Rollback(int level)
-
level optional number of levels to roll back.
This method does nothing if
level is less than
0, and stops rolling back once the transaction level reaches
0 if
level is greater than the initial transaction level.
Event.
Store() stores a .NET object or array of objects as persistent events. There is no significant performance difference between passing an array and passing individual objects in a loop, but all objects in the array must be of the same type. Returns a
long database ID for each newly inserted object, or
0 if the ID could not be returned or the event uses an IdKey.
long Store(object obj)
long[] Store(object[] objects)
-
obj .NET object to be added to the database.
-
objects array of .NET objects to be added to the database. All objects must be of the same type.
System.Collections.Generic.List<E> GetAll()
Uses
GetNext() to get all target class
E objects in the resultset, and returns them in a
List. The list cannot be used for updating or deleting (although
Event methods
UpdateObject() and
DeleteObject() can be used if you have some way of obtaining the Id or IdKey of each object).
GetAll() and
GetNext() cannot access the same resultset once either method has been called, the other method cannot be used until
Execute() is called again.
This method is more resource-intensive than a loop that explicitly calls
GetNext() for each item, since there is a high cost associated with maintaining a list of objects.
By default, properties declared as interfaces are ignored during schema generation. To change this behavior, an implementation of
InterfaceResolver can be passed to the
ImportSchema() method, providing it with information that allows it to replace an interface type with the correct concrete type.