Exemple #1
0
 internal void ConfigureFunctionParameters(
     IList <ModificationFunctionParameterBinding> parameterBindings)
 {
     foreach (KeyValuePair <PropertyPath, System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration> propertyConfiguration in this.PrimitivePropertyConfigurations)
     {
         PropertyPath propertyPath = propertyConfiguration.Key;
         propertyConfiguration.Value.ConfigureFunctionParameters(parameterBindings.Where <ModificationFunctionParameterBinding>((Func <ModificationFunctionParameterBinding, bool>)(pb =>
         {
             if (pb.MemberPath.AssociationSetEnd == null)
             {
                 return(propertyPath.Equals(new PropertyPath(pb.MemberPath.Members.Skip <EdmMember>(pb.MemberPath.Members.Count - propertyPath.Count).Select <EdmMember, PropertyInfo>((Func <EdmMember, PropertyInfo>)(m => m.GetClrPropertyInfo())))));
             }
             return(false);
         })).Select <ModificationFunctionParameterBinding, FunctionParameter>((Func <ModificationFunctionParameterBinding, FunctionParameter>)(pb => pb.Parameter)));
     }
 }
            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                {
                    return(false);
                }

                if (ReferenceEquals(this, obj))
                {
                    return(true);
                }

                var other = (ParameterKey)obj;

                return(_propertyPath.Equals(other._propertyPath) &&
                       _rightKey.Equals(other._rightKey));
            }
Exemple #3
0
 internal void ConfigurePropertyMappings(
     IList <Tuple <ColumnMappingBuilder, EntityType> > propertyMappings,
     DbProviderManifest providerManifest,
     bool allowOverride = false)
 {
     foreach (KeyValuePair <PropertyPath, System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration> propertyConfiguration in this._primitivePropertyConfigurations)
     {
         PropertyPath propertyPath = propertyConfiguration.Key;
         propertyConfiguration.Value.Configure(propertyMappings.Where <Tuple <ColumnMappingBuilder, EntityType> >((Func <Tuple <ColumnMappingBuilder, EntityType>, bool>)(pm =>
         {
             if (propertyPath.Equals(new PropertyPath(pm.Item1.PropertyPath.Skip <EdmProperty>(pm.Item1.PropertyPath.Count - propertyPath.Count).Select <EdmProperty, PropertyInfo>((Func <EdmProperty, PropertyInfo>)(p => p.GetClrPropertyInfo())))))
             {
                 return(object.Equals((object)this.TableName, (object)pm.Item2.GetTableName()));
             }
             return(false);
         })), providerManifest, allowOverride, true);
     }
 }
        /// <summary>
        /// Ensures that a triple consisting of a particular variable, a given property path and any other variable is a part of the graph.
        /// </summary>
        /// <param name="fromVariable">The variable that will be used as the triple subject.</param>
        /// <param name="path">The property path that forms the triple predicate.</param>
        /// <returns>The variable that serves as the triple object.</returns>
        /// <exception cref="ArgumentNullException">Any of the arguments is <see langword="null"/>.</exception>
        public Variable AddVariableTriple(Variable fromVariable, PropertyPath path)
        {
            if (fromVariable == null)
            {
                throw new ArgumentNullException("fromVariable");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            foreach (var t in statements.OfType <Triple>())
            {
                var varSubject = t.Subject as VariableEnd;
                if (varSubject != null)
                {
                    if (varSubject.Variable == fromVariable)
                    {
                        var varObject = t.Object as VariableEnd;
                        if (varObject != null)
                        {
                            var pathPredicate = t.Predicate as PropertyPath;
                            if (pathPredicate != null)
                            {
                                if (path.Equals(pathPredicate))
                                {
                                    return(varObject.Variable);
                                }
                            }
                        }
                    }
                }
            }

            var newVar = new Variable();

            AddTriple(new VariableEnd(fromVariable),
                      path,
                      new VariableEnd(newVar));
            return(newVar);
        }
Exemple #5
0
        private ColumnDescriptor FindColumnDescriptor(ColumnDescriptor start, PropertyPath propertyPath)
        {
            if (propertyPath.Equals(start.PropertyPath))
            {
                return(start);
            }

            foreach (var child in ListAllChildren(start))
            {
                if (propertyPath.StartsWith(child.PropertyPath))
                {
                    var result = FindColumnDescriptor(child, propertyPath);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }
 private bool Equals(ColumnKey other)
 {
     return(PropertyPath.Equals(other.PropertyPath));
 }
Exemple #7
0
 private void ConfigureParameters(
     ModificationFunctionMapping modificationStoredProcedureMapping)
 {
     foreach (KeyValuePair <ModificationStoredProcedureConfiguration.ParameterKey, Tuple <string, string> > parameterName in this._parameterNames)
     {
         PropertyPath propertyPath = parameterName.Key.PropertyPath;
         string       str1         = parameterName.Value.Item1;
         string       str2         = parameterName.Value.Item2;
         List <ModificationFunctionParameterBinding> list = modificationStoredProcedureMapping.ParameterBindings.Where <ModificationFunctionParameterBinding>((Func <ModificationFunctionParameterBinding, bool>)(pb =>
         {
             if ((pb.MemberPath.AssociationSetEnd == null || pb.MemberPath.AssociationSetEnd.ParentAssociationSet.ElementType.IsManyToMany()) && propertyPath.Equals(new PropertyPath(pb.MemberPath.Members.OfType <EdmProperty>().Select <EdmProperty, PropertyInfo>((Func <EdmProperty, PropertyInfo>)(m => m.GetClrPropertyInfo())))))
             {
                 return(true);
             }
             if (propertyPath.Count == 2 && pb.MemberPath.AssociationSetEnd != null && pb.MemberPath.Members.First <EdmMember>().GetClrPropertyInfo().IsSameAs(propertyPath.Last <PropertyInfo>()))
             {
                 return(pb.MemberPath.AssociationSetEnd.ParentAssociationSet.AssociationSetEnds.Select <AssociationSetEnd, PropertyInfo>((Func <AssociationSetEnd, PropertyInfo>)(ae => ae.CorrespondingAssociationEndMember.GetClrPropertyInfo())).Where <PropertyInfo>((Func <PropertyInfo, bool>)(pi => pi != (PropertyInfo)null)).Any <PropertyInfo>((Func <PropertyInfo, bool>)(pi => pi.IsSameAs(propertyPath.First <PropertyInfo>()))));
             }
             return(false);
         })).ToList <ModificationFunctionParameterBinding>();
         if (list.Count == 1)
         {
             ModificationFunctionParameterBinding parameterBinding = list.Single <ModificationFunctionParameterBinding>();
             if (!string.IsNullOrWhiteSpace(str2) && parameterBinding.IsCurrent)
             {
                 throw Error.ModificationFunctionParameterNotFoundOriginal((object)propertyPath, (object)modificationStoredProcedureMapping.Function.FunctionName);
             }
             parameterBinding.Parameter.Name = str1;
             this._configuredParameters.Add(parameterBinding.Parameter);
         }
         else
         {
             if (list.Count != 2)
             {
                 throw Error.ModificationFunctionParameterNotFound((object)propertyPath, (object)modificationStoredProcedureMapping.Function.FunctionName);
             }
             ModificationFunctionParameterBinding parameterBinding1 = list.Select <ModificationFunctionParameterBinding, bool>((Func <ModificationFunctionParameterBinding, bool>)(pb => pb.IsCurrent)).Distinct <bool>().Count <bool>() != 1 || !list.All <ModificationFunctionParameterBinding>((Func <ModificationFunctionParameterBinding, bool>)(pb => pb.MemberPath.AssociationSetEnd != null)) ? list.Single <ModificationFunctionParameterBinding>((Func <ModificationFunctionParameterBinding, bool>)(pb => pb.IsCurrent)) : (!parameterName.Key.IsRightKey ? list.First <ModificationFunctionParameterBinding>() : list.Last <ModificationFunctionParameterBinding>());
             parameterBinding1.Parameter.Name = str1;
             this._configuredParameters.Add(parameterBinding1.Parameter);
             if (!string.IsNullOrWhiteSpace(str2))
             {
                 ModificationFunctionParameterBinding parameterBinding2 = list.Single <ModificationFunctionParameterBinding>((Func <ModificationFunctionParameterBinding, bool>)(pb => !pb.IsCurrent));
                 parameterBinding2.Parameter.Name = str2;
                 this._configuredParameters.Add(parameterBinding2.Parameter);
             }
         }
     }
     foreach (FunctionParameter functionParameter in modificationStoredProcedureMapping.Function.Parameters.Except <FunctionParameter>((IEnumerable <FunctionParameter>) this._configuredParameters))
     {
         functionParameter.Name = ((IEnumerable <INamedDataModelItem>)modificationStoredProcedureMapping.Function.Parameters.Except <FunctionParameter>((IEnumerable <FunctionParameter>) new FunctionParameter[1]
         {
             functionParameter
         })).UniquifyName(functionParameter.Name);
     }
 }