Example #1
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);
     }
 }