Inserting an Object
Here is standard .NET (C#) code that uses proxy classes to create a new PERSON record and store it in Caché. In detail, the method does the following:
Uses the proxy class constructor to create a new PERSON proxy object. This simultaneously creates a new instance of MVFILE.PERSON in Caché. Note that the constructor takes an open CacheConnection instance as an argument.
Assigns values to the proxy object's properties.
Invokes the proxy object's Save method. This saves the corresponding Caché object to the database.
MVFILE.PERSON person = new MVFILE.PERSON(cnCache); person.Name = "Smith,John"; person.Hair = "Blond"; person.Age = "42"; person.ItemId = "10"; CacheListOfStrings phones = person.Phone; phones.Add("111-222-3333"); phones.Add("444-555-6666"); phones.Add("777-888-9999"); CacheStatus status = person.Save();
Please note that the ItemId property is required and its value must be unique. If your database already contains a PERSON object with an ItemId of 10, then you must change the example code to assign a different value that has not been used.
The above code is contained in ObjectAccess.cs. This file is in <cachesys>\Dev\tutorials\mv. Executing the .NET Examples contains step-by-step instructions for executing this code.