Example #1
0
        internal ConventionNavigationPropertyConfiguration NavigationProperty(
            PropertyPath propertyPath)
        {
            this.ValidateConfiguration(ConventionTypeConfiguration.ConfigurationAspect.NavigationProperty);
            PropertyInfo propertyInfo = propertyPath.Last <PropertyInfo>();

            if (!propertyInfo.IsValidEdmNavigationProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_InvalidNavigationProperty((object)propertyPath));
            }
            return(new ConventionNavigationPropertyConfiguration(this._entityTypeConfiguration != null ? this._entityTypeConfiguration().Navigation(propertyInfo) : (NavigationPropertyConfiguration)null, this._modelConfiguration));
        }
Example #2
0
        internal ConventionPrimitivePropertyConfiguration Property(
            PropertyPath propertyPath)
        {
            this.ValidateConfiguration(ConventionTypeConfiguration.ConfigurationAspect.Property);
            PropertyInfo propertyInfo = propertyPath.Last <PropertyInfo>();

            if (!propertyInfo.IsValidEdmScalarProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_NonScalarProperty((object)propertyPath));
            }
            System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration propertyConfiguration = this._entityTypeConfiguration != null?this._entityTypeConfiguration().Property(propertyPath, new OverridableConfigurationParts?()) : (this._complexTypeConfiguration != null ? this._complexTypeConfiguration().Property(propertyPath, new OverridableConfigurationParts?()) : (System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration)null);

            return(new ConventionPrimitivePropertyConfiguration(propertyInfo, (Func <System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration>)(() => propertyConfiguration)));
        }
        internal LightweightPropertyConfiguration Property(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmScalarProperty() ||
                propertyInfo.GetIndexParameters().Any())
            {
                throw Error.LightweightEntityConfiguration_NonScalarProperty(propertyPath);
            }

            var propertyConfiguration = new Lazy <PrimitivePropertyConfiguration>(
                () => _configuration().Property(propertyPath, OverridableConfigurationParts.None));

            return(new LightweightPropertyConfiguration(propertyPath.Single(), () => propertyConfiguration.Value));
        }
        public T?GetPropertyValue <T>(T?defaultValue, params string[] PropertyPath)
        {
            var propertyTable = this;

            foreach (string name in PropertyPath.Take(PropertyPath.Length - 1))
            {
                var property = propertyTable[name];
                if (property != null)
                {
                    propertyTable = property.GetValue <SteamAppPropertyTable>();
                }
                if (property == null || propertyTable == null)
                {
                    return(defaultValue);
                }
            }
            return(propertyTable.GetPropertyValue(PropertyPath.Last(), defaultValue));
        }
        internal ConventionNavigationPropertyConfiguration NavigationProperty(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            ValidateConfiguration(ConfigurationAspect.NavigationProperty);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmNavigationProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_InvalidNavigationProperty(propertyPath));
            }

            var propertyConfiguration = _entityTypeConfiguration != null
                                            ? _entityTypeConfiguration().Navigation(propertyInfo)
                                            : null;

            return(new ConventionNavigationPropertyConfiguration(propertyConfiguration, _modelConfiguration));
        }
        internal PrimitivePropertyConfiguration Property(
            PropertyPath propertyPath, OverridableConfigurationParts?overridableConfigurationParts = null)
        {
            DebugCheck.NotNull(propertyPath);

            return(Property(
                       propertyPath,
                       () =>
            {
                var configuration = (PrimitivePropertyConfiguration)Activator
                                    .CreateInstance(
                    GetPropertyConfigurationType(
                        propertyPath.Last().PropertyType));

                if (overridableConfigurationParts.HasValue)
                {
                    configuration.OverridableConfigurationParts = overridableConfigurationParts.Value;
                }
                return configuration;
            }));
        }
        internal ConventionPrimitivePropertyConfiguration Property(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            ValidateConfiguration(ConfigurationAspect.Property);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmScalarProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_NonScalarProperty(propertyPath));
            }

            var propertyConfiguration = _entityTypeConfiguration != null
                                            ? _entityTypeConfiguration().Property(propertyPath)
                                            : _complexTypeConfiguration != null
                                                  ? _complexTypeConfiguration().Property(propertyPath)
                                                  : null;

            return(new ConventionPrimitivePropertyConfiguration(propertyInfo, () => propertyConfiguration));
        }
Example #8
0
 internal System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration Property(
     PropertyPath propertyPath,
     OverridableConfigurationParts?overridableConfigurationParts = null)
 {
     return(this.Property <System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration>(propertyPath, (Func <System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration>)(() =>
     {
         System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration instance = (System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration)Activator.CreateInstance(StructuralTypeConfiguration.GetPropertyConfigurationType(propertyPath.Last <PropertyInfo>().PropertyType));
         instance.TypeConfiguration = this;
         if (overridableConfigurationParts.HasValue)
         {
             instance.OverridableConfigurationParts = overridableConfigurationParts.Value;
         }
         return instance;
     })));
 }
Example #9
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);
     }
 }
        internal ConventionNavigationPropertyConfiguration NavigationProperty(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            ValidateConfiguration(ConfigurationAspect.NavigationProperty);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmNavigationProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_InvalidNavigationProperty(propertyPath));
            }

            var propertyConfiguration = _entityTypeConfiguration != null
                                            ? _entityTypeConfiguration().Navigation(propertyInfo)
                                            : null;

            return new ConventionNavigationPropertyConfiguration(propertyConfiguration, _modelConfiguration);
        }
        internal ConventionPrimitivePropertyConfiguration Property(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            ValidateConfiguration(ConfigurationAspect.Property);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmScalarProperty())
            {
                throw new InvalidOperationException(Strings.LightweightEntityConfiguration_NonScalarProperty(propertyPath));
            }

            var propertyConfiguration = _entityTypeConfiguration != null
                                            ? _entityTypeConfiguration().Property(propertyPath)
                                            : _complexTypeConfiguration != null
                                                  ? _complexTypeConfiguration().Property(propertyPath)
                                                  : null;

            return new ConventionPrimitivePropertyConfiguration(propertyInfo, () => propertyConfiguration);
        }
        internal LightweightPropertyConfiguration Property(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmScalarProperty()
                || propertyInfo.GetIndexParameters().Any())
            {
                throw Error.LightweightEntityConfiguration_NonScalarProperty(propertyPath);
            }

            var propertyConfiguration = new Lazy<PrimitivePropertyConfiguration>(
                () => _configuration().Property(propertyPath, OverridableConfigurationParts.None));

            return new LightweightPropertyConfiguration(propertyPath.Single(), () => propertyConfiguration.Value);
        }
        internal ConventionPrimitivePropertyConfiguration Property(PropertyPath propertyPath)
        {
            DebugCheck.NotNull(propertyPath);

            ValidateConfiguration(ConfigurationAspect.Property);

            var propertyInfo = propertyPath.Last();

            if (!propertyInfo.IsValidEdmScalarProperty())
            {
                throw Error.LightweightEntityConfiguration_NonScalarProperty(propertyPath);
            }

            var propertyConfiguration = _entityTypeConfiguration != null
                                            ? _entityTypeConfiguration().Property(propertyPath, OverridableConfigurationParts.None)
                                            : _complexTypeConfiguration != null
                                                  ? _complexTypeConfiguration().Property(propertyPath, OverridableConfigurationParts.None)
                                                  : null;

            return new ConventionPrimitivePropertyConfiguration(propertyInfo, () => propertyConfiguration);
        }