Creating a New Object
Here is a sample of .NET code that does the following:
-
Creates a new instance of Provider.Contact.
-
Assigns values to the new Contact instance's Name and ContactType properties.
-
Saves the new Contact instance.
-
Uses the CacheStatus instance returned from Save to determine whether the object was successfully saved.
-
If the Contact instance is saved, it writes the new object's ID value to the console. Note that a Caché object only acquires an object ID the first time it is saved.
-
If the Contact instance is not saved, it writes an error message to the console.
try
{
Provider.Contact contact = new Provider.Contact(cnCache);
contact.Name = "Smith,John";
contact.ContactType = "Business";
CacheStatus status = contact.Save();
if (status.IsOK)
{
Console.WriteLine("Id is: {0}" , contact.Id());
}
else
{
Console.WriteLine("Error creating object");
}
}
catch (Exception e) { }
Note that cnCache represents an open CacheConnection instance.