Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Creating a New Object

Here is a sample of .NET code that does the following:

  1. Creates a new instance of Provider.Contact.

  2. Assigns values to the new Contact instance's Name and ContactType properties.

  3. Saves the new Contact instance.

  4. Uses the CacheStatus instance returned from Save to determine whether the object was successfully saved.

  5. 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.

  6. If the Contact instance is not saved, it writes an error message to the console.

    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());
      Console.WriteLine("Error creating object");
catch (Exception e) { }     
Copy code to clipboard

Note that cnCache represents an open CacheConnection instance.

FeedbackOpens in a new window