コード例 #1
0
        public object GetResource(IQueryable query, string fullTypeName)
        {
            object obj;

            TraceHelper.Current.MethodCall2("DataServiceUpdateProvider", "GetResource", query.ToString(), fullTypeName);
            try
            {
                DSLinqQueryProvider provider = query.Provider as DSLinqQueryProvider;
                ExceptionHelpers.ThrowArgumentExceptionIf("query", provider == null, Resources.QueryDoesNotIncludePswsProvider, new object[0]);
                if (!provider.IsFilterOverResourceRoot(query.Expression))
                {
                    ReferredResourceExtractor referredResourceExtractor = new ReferredResourceExtractor();
                    DSResource current = null;
                    if (!referredResourceExtractor.Extract(query.Expression, provider.GetInitialQueryable(), provider.GetInitialResourceType(), provider.GetEntityMetadata(provider.GetInitialResourceType())))
                    {
                        IEnumerator <DSResource> enumerator = (query.GetEnumerator() as IEnumerable <DSResource>).GetEnumerator();
                        if (enumerator.MoveNext())
                        {
                            current = enumerator.Current;
                            if (enumerator.MoveNext())
                            {
                                throw new ArgumentException("multiple instances");
                            }
                        }
                        else
                        {
                            throw new ArgumentException("no instances");
                        }
                    }
                    else
                    {
                        current = referredResourceExtractor.ReferredResource;
                    }
                    ResourceType    resourceType           = current.ResourceType;
                    EntityMetadata  entityMetadata         = provider.GetEntityMetadata(resourceType);
                    IUpdateInstance referredEntityInstance = new ReferredEntityInstance(current, this.dataContext.UserContext, resourceType, entityMetadata, this.dataContext.MembershipId);
                    this.instances.Add(referredEntityInstance);
                    obj = referredEntityInstance;
                }
                else
                {
                    ResourceType   initialResourceType = provider.GetInitialResourceType();
                    EntityMetadata entityMetadatum     = provider.GetEntityMetadata(initialResourceType);
                    this.entityInstance = new EntityUpdate(CommandType.Update, this.dataContext.UserContext, initialResourceType, entityMetadatum, query, this.dataContext.MembershipId);
                    this.instances.Add(this.entityInstance);
                    obj = this.entityInstance;
                }
            }
            catch (ArgumentException argumentException1)
            {
                ArgumentException argumentException = argumentException1;
                TraceHelper.Current.InvalidUpdateQuery(fullTypeName, query.ToString(), argumentException.GetType().ToString(), argumentException.Message);
                obj = null;
            }
            return(obj);
        }
コード例 #2
0
        public IQueryable GetQueryRootForResourceSet(ResourceSet resourceSet)
        {
            IQueryable queryables;
            string     name;
            Tracer     current = TraceHelper.Current;
            string     str     = "DataServiceQueryProvider";
            string     str1    = "GetQueryRootForResourceSet";

            if (resourceSet == null)
            {
                name = "<null>";
            }
            else
            {
                name = resourceSet.Name;
            }
            current.MethodCall1(str, str1, name);
            object[] objArray = new object[2];
            objArray[0] = "resourceProperty";
            objArray[1] = "DataServiceQueryProvider.GetQueryRootForResourceSet";
            resourceSet.ThrowIfNull("resourceSet", new ParameterExtensions.MessageLoader(DataServiceQueryProvider.GetInputVariableToODataMethodNullMessage), objArray);
            try
            {
                using (OperationTracer operationTracer = new OperationTracer("GetQueryRoot"))
                {
                    queryables = DSLinqQueryProvider.CreateQuery(this.dataContext.UserSchema, resourceSet.ResourceType, this.dataContext.UserContext, this.dataContext.MembershipId, this.resultSets);
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                exception.Trace(null);
                TraceHelper.Current.QueryGetQueryRootForResourceFailed(this.dataContext.UserContext.Name, resourceSet.Name);
                throw;
            }
            return(queryables);
        }
コード例 #3
0
        internal static IQueryable CreateQuery(Microsoft.Management.Odata.Schema.Schema schema, ResourceType type, UserContext userContext, string membershipId, DataServiceQueryProvider.ResultSetCollection resultSets)
        {
            DSLinqQueryProvider dSLinqQueryProvider = new DSLinqQueryProvider(schema, type, userContext, membershipId, resultSets);

            return(dSLinqQueryProvider.CreateRootQuery());
        }
コード例 #4
0
ファイル: DSLinqQuery`1.cs プロジェクト: modulexcite/pash-1
 internal DSLinqQuery(DSLinqQueryProvider queryProvider, Expression queryExpression)
 {
     this.Provider   = queryProvider;
     this.Expression = queryExpression;
 }