public IEnumerable LoadPropertyPage <TEntity>(object entity, string propertyName, DataServiceQueryContinuation <TEntity> continuation)
        {
            QueryOperationResponse qoLoadPropResponse = null;

            SocketExceptionHandler.Execute(() => qoLoadPropResponse = this._DataServiceContext.LoadProperty(entity, propertyName, continuation));
            return(new QueryOperationResponseWrapper(qoLoadPropResponse));
        }
Esempio n. 2
0
        public override KeyExpressions GetAllExistingKeysOfType(ResourceContainer resourceContainer, ResourceType resourceType)
        {
            if (!DataGenerator.Done)
            {
                return(DataGenerator.GetAllGeneratedKeys(resourceContainer, resourceType));
            }

            bool            rightsChanged = false;
            EntitySetRights oldRights     = this.DataService.ConfigSettings.GetEntitySetAccessRule(resourceContainer.Name);

            if ((EntitySetRights.ReadMultiple & oldRights) == 0)
            {
                rightsChanged = true;
                this.DataService.ConfigSettings.SetEntitySetAccessRule(resourceContainer.Name, EntitySetRights.All);
            }

            KeyExpressions keys = SocketExceptionHandler.Execute <KeyExpressions>(
                () => GetAllExistingKeysBase(resourceContainer));

            if (rightsChanged)
            {
                this.DataService.ConfigSettings.SetEntitySetAccessRule(resourceContainer.Name, oldRights);
            }

            if (resourceType == null)
            {
                return(keys);
            }

            return(new KeyExpressions(keys.Where(k => k.ResourceType.Equals(resourceType))));
        }
Esempio n. 3
0
        public override KeyedResourceInstance GetSingleResourceByKey(KeyExpression keyExpression)
        {
            if (keyExpression.Properties.OfType <ResourceProperty>().Where(rp => rp.Type.ClrType.Equals(typeof(DateTime))).Count() > 0)
            {
                UriQueryBuilder uriQueryBuilder = new UriQueryBuilder(this, this.ServiceUri);
                _workaroundDateTimeQuery = uriQueryBuilder.Build(Query.From(
                                                                     Exp.Variable(keyExpression.ResourceContainer))
                                                                 .Where(keyExpression)
                                                                 .Select());
            }
            KeyedResourceInstance o = null;

            try
            {
                o = SocketExceptionHandler.Execute <KeyedResourceInstance>(
                    () => GetSingleResourceByKeyBase(keyExpression));
            }
            catch (Microsoft.OData.Client.DataServiceQueryException exc)
            {
                if (exc.Response.StatusCode != 404)
                {
                    throw exc;
                }

                // if DSV is not present, its not an Astoria-level error
                if (!exc.Response.Headers.ContainsKey("OData-Version"))
                {
                    throw exc;
                }
            }

            return(o);
        }
Esempio n. 4
0
        public IEnumerable ClientExecuteWrapper <T>(string query, ResourceContainer container)
        {
            // we need to wrap the invoked call to execute because
            // it can throw a web exception if we run out of sockets
            DataServiceContext ctx;

            Microsoft.OData.Client.ODataProtocolVersion?maxProtocolVersion = null;

            // do this agressively, as we weren't successful at predicting when we actually needed it
            maxProtocolVersion = Microsoft.OData.Client.ODataProtocolVersion.V4;

            if (maxProtocolVersion.HasValue)
            {
                ctx = new DataServiceContext(new Uri(this.ServiceUri), maxProtocolVersion.Value);
            }
            else
            {
                ctx = new DataServiceContext(new Uri(this.ServiceUri));
            }

            //ctx.UndeclaredPropertyBehavior = UndeclaredPropertyBehavior.Support;
            ctx.Configurations.RequestPipeline.OnMessageCreating = this.ctx_OnMessageCreating;

            return(SocketExceptionHandler.Execute <IEnumerable>(() => (IEnumerable)ctx.Execute <T>(new Uri(query))));
        }
Esempio n. 5
0
        public static System.Collections.ArrayList CreateList(IQueryable baseline)
        {
            // Get all the data into a list (this closes reader so that "Load" can be called on nested elements)
            System.Collections.ArrayList list = new System.Collections.ArrayList();

            // we know that this thing is potentially a DataServiceQuery, so get the enumerator safely
            IEnumerator enumerator = SocketExceptionHandler.Execute <IEnumerator>(baseline.GetEnumerator);

            while (enumerator.MoveNext())
            {
                list.Add(enumerator.Current);
            }

            return(list);
        }