コード例 #1
0
 internal string Format(ODataClientWithCommand client, Table table)
 {
     return this.Format(new ExpressionContext()
                            {
                                Client = client, 
                                Table = table
                            });
 }
コード例 #2
0
        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;
        }
コード例 #3
0
 public ODataCommand(ODataClientWithCommand client, ODataCommand parent)
 {
     _client = client;
     _parent = parent;
 }
コード例 #4
0
        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");
            }
        }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
 internal string Format(ODataClientWithCommand client, string collection)
 {
     return this.Format(new ExpressionContext { Client = client, Collection = collection });
 }
コード例 #8
0
 public ODataClientWithCommand Link(ODataCommand command, string linkName)
 {
     var linkedClient = new ODataClientWithCommand(_client, _schema, command);
     linkedClient._command.Link(linkName);
     return linkedClient;
 }