Insert/Update
Use the set
and save
methods to write data to a table in a data source using an ORM entity class.
Insert
The following example will insert a new record into the Categories
table with a CategoryName
of Custom Category
. This will automatically be an INSERT
operation as the primary key field on the table CategoryId
was not supplied.
The save method will return an array of new primary key values for inserted records.
Update
After the line of code above is executed, the keys array will contain the CategoryId
for the newly added record.
The example below updates the CatgoryName
field for this new record to My Category
by including the key field CatagoryID
in the update with the key value.
To update records in the table without the key value, use the eq
to set a value based one of the other fields.
The example below changes the CategoryName
field value to My Category
where the field Description
is This is my description
.
Last updated