public int UpdateEntry(string tableName, IDictionary <string, object> entryKey, IDictionary <string, object> entryData) { bool merge = CheckMergeConditions(tableName, entryKey, entryData); var commandText = FormatGetKeyCommand(tableName, entryKey); var entryMembers = ParseEntryMembers(tableName, entryData); var entryElement = ODataHelper.CreateDataElement(entryMembers.Properties); foreach (var association in entryMembers.AssociationsByValue) { CreateLinkElement(entryElement, tableName, association); } var command = new HttpCommand(merge ? RestVerbs.MERGE : RestVerbs.PUT, commandText, entryData, entryElement.ToString()); _requestBuilder.AddCommandToRequest(command); var result = _requestRunner.UpdateEntry(command); foreach (var association in entryMembers.AssociationsByContentId) { var linkCommand = CreateLinkCommand(tableName, association.Key, command.ContentId, association.Value); _requestBuilder.AddCommandToRequest(linkCommand); _requestRunner.UpdateEntry(linkCommand); } return(result); }
public void LinkEntry(string tableName, IDictionary <string, object> entryKey, string linkName, IDictionary <string, object> linkedEntryKey) { var association = _schema.FindTable(tableName).FindAssociation(linkName); var command = CreateLinkCommand(tableName, linkName, FormatGetKeyCommand(tableName, entryKey), FormatGetKeyCommand(association.ReferenceTableName, linkedEntryKey)); _requestBuilder.AddCommandToRequest(command); _requestRunner.UpdateEntry(command); }