Click or drag to resize

FunctionsUpdate Method

Linkar Framework for .NET and Core


Update one or several records of a file, synchronously only, with JSON input and output format.

Namespace: Linkar.Functions.Direct.JSON
Assembly: Linkar.Functions.Direct.JSON (in Linkar.Functions.Direct.JSON.dll) Version: 2.3.1
Syntax
public static string Update(
	CredentialOptions credentialOptions,
	string filename,
	string records,
	UpdateOptions updateOptions = null,
	FunctionsJSON_FORMAT jsonFormat = FunctionsJSON_FORMAT.JSON,
	string customVars = "",
	int receiveTimeout = 0
)

Parameters

credentialOptions  CredentialOptions
Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.
filename  String
Name of the file being updated.
records  String
Buffer of record data to update. Inside this string are the recordIds, the modified records, and the originalRecords.
updateOptions  UpdateOptions  (Optional)
Object with write options, including optimisticLockControl, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.
jsonFormat  FunctionsJSON_FORMAT  (Optional)
Enum JSON_FORMAT specifies the desired output format: standard JSON, JSON_DICT format, or JSON_SCH format
customVars  String  (Optional)
Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.
receiveTimeout  Int32  (Optional)
Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.

Return Value

String
The results of the operation.
Remarks
Inside the records argument, the recordIds and the modified records always must be specified. But the originalRecords not always. When updateOptions argument is specified and the OptimisticLockControl property is set to true, a copy of the record must be provided before the modification (originalRecords argument) to use the Optimistic Lock technique. This copy can be obtained from a previous Read(CredentialOptions, String, String, String, ReadOptions, FunctionsJSON_FORMAT, String, Int32) operation. The database, before executing the modification, reads the record and compares it with the copy in originalRecords, if they are equal the modified record is executed. But if they are not equal, it means that the record has been modified by other user and its modification will not be saved. The record will have to be read, modified and saved again.
Example
using Linkar;
using Linkar.Functions.Direct.JSON;

class Test
    {
        public string MyUpdate()
        {
            string result = "";
            try
            {
                CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");

                result = Functions.Update(credentials, "LK.CUSTOMERS",
                    "{" +
                    "  \"RECORDS\": [" +
                    "    {" +
                    "      \"LKITEMID\": \"2\"," +
                    "      \"NAME": \"CUSTOMER 2\"," +
                    "      \"ADDR": \"ADDRESS 2\"," +
                    "      \"PHONE": \"444\"" +
                    "    }" +
                    "  ]" +
                    "}");
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                // Do something
            }
            return result;
        }
    }
See Also