Exemple #1
0
 public static bool IsNavPropertyHasGetReferenceCmdlet(this ResourceProperty resourceProperty, EntityMetadata entityMetadata)
 {
     if (resourceProperty.IsReferenceSetProperty())
     {
         PSEntityMetadata pSEntityMetadatum = entityMetadata as PSEntityMetadata;
         PSEntityMetadata.ReferenceSetCmdlets referenceSetCmdlet = null;
         if (!pSEntityMetadatum.CmdletsForReferenceSets.TryGetValue(resourceProperty.Name, out referenceSetCmdlet) || !referenceSetCmdlet.Cmdlets.ContainsKey(CommandType.GetReference))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
Exemple #2
0
        public object GetValue(string propertyName, DataServiceQueryProvider.ResultSetCollection resultSets = null)
        {
            object obj = null;
            Func <ResourceProperty, bool> func = null;

            if (!this.ContainsNonKeyProperties && resultSets != null)
            {
                if (this.completeObject == null)
                {
                    ReadOnlyCollection <ResourceProperty> properties = this.ResourceType.Properties;
                    if (func == null)
                    {
                        func = (ResourceProperty it) => string.Equals(propertyName, it.Name, StringComparison.Ordinal);
                    }
                    ResourceProperty resourceProperty = properties.FirstOrDefault <ResourceProperty>(func);
                    bool             flag             = false;
                    if (!resourceProperty.IsKeyProperty())
                    {
                        if (resourceProperty.IsReferenceSetProperty())
                        {
                            flag = !this.properties.ContainsKey(propertyName);
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        this.UpdateCompleteObject(resultSets);
                    }
                }
                if (this.completeObject != null)
                {
                    return(this.completeObject.GetValue(propertyName, resultSets));
                }
            }
            if (!this.properties.TryGetValue(propertyName, out obj))
            {
                if (this.ResourceType.Properties.Any <ResourceProperty>((ResourceProperty item) => item.Name == propertyName))
                {
                    return(null);
                }
                else
                {
                    throw new ResourcePropertyNotFoundException(this.ResourceType.Name, propertyName);
                }
            }
            else
            {
                if (obj != null)
                {
                    IReferencedResourceSet referencedResourceSet = obj as IReferencedResourceSet;
                    if (referencedResourceSet != null)
                    {
                        Dictionary <string, object> strs = new Dictionary <string, object>();
                        foreach (ResourceProperty keyProperty in this.ResourceType.KeyProperties)
                        {
                            object obj1 = null;
                            if (this.properties.TryGetValue(keyProperty.Name, out obj1))
                            {
                                strs.Add(keyProperty.Name, obj1);
                            }
                            else
                            {
                                throw new ResourcePropertyNotFoundException(this.ResourceType.Name, keyProperty.Name);
                            }
                        }
                        List <DSResource> dSResources = referencedResourceSet.Get(strs);
                        this.properties[propertyName] = dSResources;
                        return(dSResources);
                    }
                }
                return(obj);
            }
        }