Memory objects not containing an OID Property set, may be persisted to a Siaqodb database using the UpdateObjectBy(…) method. This method allows the caller to specify the Fields to store. Usually one of these fields is an ID managed by an external database.

Object stored with the UpdateObjectBy method may subsequently be retrieved using a query for the external ID Field. Objects persisted with the UpdateObjectBy method can be deleted using the DeleteObjectBy method.

An example of using the UpdateObjectBy method is shown below:

Example:

public class RecordWithManualID
    {
        public int OID { get; set; }

        private Guid _id;
        public Guid ID { get { return _id; } set { _id = value; } }

        public string Name { get; set; }
    }


......

       //prepare some data
            Guid IdKept = Guid.Empty;
            Siaqodb siaqodb = SiaqodbFactoryExample.GetInstance();
            for (int i = 0; i < 10; i++)
            {
                RecordWithManualID rec = new RecordWithManualID { ID = Guid.NewGuid(), Name = "Name" + i.ToString() };

                siaqodb.StoreObject(rec);
                if (i == 5)
                {
                    IdKept = rec.ID;
                }
            }


            RecordWithManualID recNew = new RecordWithManualID();
            recNew.Name = "Updated Name";
            recNew.ID = IdKept;

            //update object by ID(similar in relational databases with "UPDATE ....WHERE ID=yourID"
            siaqodb.UpdateObjectBy("_id", recNew);
            //or use overloaded method:
            //siaqodb.UpdateObjectBy(recNew, new string[] { "_id" });