internal string Format(ODataClientWithCommand client, Table table) { return this.Format(new ExpressionContext() { Client = client, Table = table }); }
private int UpdateEntryPropertiesAndAssociations( string collection, IDictionary<string, object> entryKey, IDictionary<string, object> entryData, EntryMembers entryMembers) { bool hasPropertiesToUpdate = entryMembers.Properties.Count > 0; bool merge = !hasPropertiesToUpdate || CheckMergeConditions(collection, entryKey, entryData); var commandText = new ODataClientWithCommand(this, _schema).For(_schema.FindBaseTable(collection).ActualName).Key(entryKey).CommandText; var feedWriter = new ODataFeedWriter(); var table = _schema.FindConcreteTable(collection); var entryElement = feedWriter.CreateDataElement(_schema.TypesNamespace, table.ActualName, entryMembers.Properties); var unlinkAssociationNames = new List<string>(); foreach (var associatedData in entryMembers.AssociationsByValue) { var association = table.FindAssociation(associatedData.Key); if (associatedData.Value != null) { CreateLinkElement(entryElement, collection, associatedData); } else { unlinkAssociationNames.Add(association.ActualName); } } var command = new HttpCommand(merge ? RestVerbs.MERGE : RestVerbs.PUT, commandText, entryData, entryElement.ToString()); _requestBuilder.AddCommandToRequest(command); var result = _requestRunner.UpdateEntry(command); foreach (var associatedData in entryMembers.AssociationsByContentId) { var linkCommand = CreateLinkCommand(collection, associatedData.Key, feedWriter.CreateLinkPath(command.ContentId), feedWriter.CreateLinkPath(associatedData.Value)); _requestBuilder.AddCommandToRequest(linkCommand); _requestRunner.UpdateEntry(linkCommand); } foreach (var associationName in unlinkAssociationNames) { UnlinkEntry(collection, entryKey, associationName); } return result; }
public ODataCommand(ODataClientWithCommand client, ODataCommand parent) { _client = client; _parent = parent; }
public string FormatFilter(string collection, dynamic filterExpression) { if (filterExpression is FilterExpression) { var clientWithCommand = new ODataClientWithCommand(this, _schema); string filter = (filterExpression as FilterExpression) .Format(clientWithCommand, collection); return clientWithCommand .For(collection) .Filter(filter).CommandText; } else { throw new InvalidOperationException("Unable to cast dynamic object to FilterExpression"); } }
public int DeleteEntry(string collection, IDictionary<string, object> entryKey) { RemoveSystemProperties(entryKey); var commandText = new ODataClientWithCommand(this, _schema).For(collection).Key(entryKey).CommandText; var command = HttpCommand.Delete(commandText); _requestBuilder.AddCommandToRequest(command); return _requestRunner.DeleteEntry(command); }
public IDictionary<string, object> GetEntry(string collection, IDictionary<string, object> entryKey) { var commandText = new ODataClientWithCommand(this, _schema).For(collection).Key(entryKey).CommandText; var command = HttpCommand.Get(commandText); _requestBuilder.AddCommandToRequest(command); return _requestRunner.GetEntry(command); }
internal string Format(ODataClientWithCommand client, string collection) { return this.Format(new ExpressionContext { Client = client, Collection = collection }); }
public ODataClientWithCommand Link(ODataCommand command, string linkName) { var linkedClient = new ODataClientWithCommand(_client, _schema, command); linkedClient._command.Link(linkName); return linkedClient; }