Exemple #1
0
        private DSResource GetOriginalResource()
        {
            DSResource dSResource;
            ICommand   command = DataServiceController.Current.GetCommand(CommandType.Read, this.userContext, this.resourceType, this.metadata, this.membershipId);

            using (command)
            {
                UriParametersHelper.AddParametersToCommand(command, DataServiceController.Current.GetCurrentResourceUri());
                CommandArgumentVisitor commandArgumentVisitor = new CommandArgumentVisitor(command);
                commandArgumentVisitor.Visit(this.query.Expression);
                List <DSResource> dSResources = new List <DSResource>();
                DataServiceController.Current.QuotaSystem.CheckCmdletExecutionQuota(this.userContext);
                IEnumerator <DSResource> enumerator = command.InvokeAsync(dSResources.AsQueryable <DSResource>().Expression, true);
                while (enumerator.MoveNext())
                {
                    dSResources.Add(enumerator.Current);
                }
                if (dSResources.Count != 0)
                {
                    dSResource = dSResources.First <DSResource>();
                }
                else
                {
                    throw new DataServiceException(0x194, ExceptionHelpers.GetDataServiceExceptionMessage(HttpStatusCode.NotFound, Resources.ResourceInstanceNotFound, new object[0]));
                }
            }
            return(dSResource);
        }
Exemple #2
0
		public EntityUpdate(CommandType commandType, UserContext userContext, ResourceType type, EntityMetadata metadata, IQueryable query, string membershipId)
		{
			ExceptionHelpers.ThrowArgumentExceptionIf("commandType", commandType != CommandType.Update, Resources.InternalErrorOccurred, new object[0]);
			this.query = query;
			this.userContext = userContext;
			this.membershipId = membershipId;
			this.resourceType = type;
			this.metadata = metadata;
			this.commandType = commandType;
			this.propertyUpdates = new SortedDictionary<string, object>();
			this.updatedResource = null;
			this.resolveResource = null;
			CommandArgumentVisitor commandArgumentVisitor = new CommandArgumentVisitor(this);
			commandArgumentVisitor.Visit(query.Expression);
			if (this.AreAllKeyFieldsSpecified())
			{
				return;
			}
			else
			{
				throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.KeysMissingInQuery, new object[0]));
			}
		}
Exemple #3
0
        public EntityUpdate(CommandType commandType, UserContext userContext, ResourceType type, EntityMetadata metadata, IQueryable query, string membershipId)
        {
            ExceptionHelpers.ThrowArgumentExceptionIf("commandType", commandType != CommandType.Update, Resources.InternalErrorOccurred, new object[0]);
            this.query           = query;
            this.userContext     = userContext;
            this.membershipId    = membershipId;
            this.resourceType    = type;
            this.metadata        = metadata;
            this.commandType     = commandType;
            this.propertyUpdates = new SortedDictionary <string, object>();
            this.updatedResource = null;
            this.resolveResource = null;
            CommandArgumentVisitor commandArgumentVisitor = new CommandArgumentVisitor(this);

            commandArgumentVisitor.Visit(query.Expression);
            if (this.AreAllKeyFieldsSpecified())
            {
                return;
            }
            else
            {
                throw new ArgumentException(ExceptionHelpers.GetExceptionMessage(Resources.KeysMissingInQuery, new object[0]));
            }
        }
Exemple #4
0
		private DSResource GetOriginalResource()
		{
			DSResource dSResource;
			ICommand command = DataServiceController.Current.GetCommand(CommandType.Read, this.userContext, this.resourceType, this.metadata, this.membershipId);
			using (command)
			{
				UriParametersHelper.AddParametersToCommand(command, DataServiceController.Current.GetCurrentResourceUri());
				CommandArgumentVisitor commandArgumentVisitor = new CommandArgumentVisitor(command);
				commandArgumentVisitor.Visit(this.query.Expression);
				List<DSResource> dSResources = new List<DSResource>();
				DataServiceController.Current.QuotaSystem.CheckCmdletExecutionQuota(this.userContext);
				IEnumerator<DSResource> enumerator = command.InvokeAsync(dSResources.AsQueryable<DSResource>().Expression, true);
				while (enumerator.MoveNext())
				{
					dSResources.Add(enumerator.Current);
				}
				if (dSResources.Count != 0)
				{
					dSResource = dSResources.First<DSResource>();
				}
				else
				{
					throw new DataServiceException(0x194, ExceptionHelpers.GetDataServiceExceptionMessage(HttpStatusCode.NotFound, Resources.ResourceInstanceNotFound, new object[0]));
				}
			}
			return dSResource;
		}