Exemplo n.º 1
0
        private static MappingFragment FindConditionTypeMappingFragment(
            EntitySet tableSet, MappingFragment propertiesTypeMappingFragment,
            EntityTypeMapping conditionTypeMapping)
        {
            var table = tableSet.ElementType;

            var conditionTypeMappingFragment
                = conditionTypeMapping.MappingFragments
                  .SingleOrDefault(x => x.Table == table);

            if (conditionTypeMappingFragment == null)
            {
                conditionTypeMappingFragment
                    = EntityMappingOperations
                      .CreateTypeMappingFragment(conditionTypeMapping, propertiesTypeMappingFragment, tableSet);

                conditionTypeMappingFragment.SetIsConditionOnlyFragment(true);

                if (propertiesTypeMappingFragment.GetDefaultDiscriminator() != null)
                {
                    conditionTypeMappingFragment.SetDefaultDiscriminator(
                        propertiesTypeMappingFragment.GetDefaultDiscriminator());
                    propertiesTypeMappingFragment.RemoveDefaultDiscriminatorAnnotation();
                }
            }
            return(conditionTypeMappingFragment);
        }
Exemplo n.º 2
0
        public static EdmProperty RemoveDefaultDiscriminatorCondition(
            this MappingFragment entityTypeMappingFragment)
        {
            EdmProperty defaultDiscriminator = entityTypeMappingFragment.GetDefaultDiscriminator();

            if (defaultDiscriminator != null && entityTypeMappingFragment.ColumnConditions.Any <ConditionPropertyMapping>())
            {
                entityTypeMappingFragment.ClearConditions();
            }
            entityTypeMappingFragment.RemoveDefaultDiscriminatorAnnotation();
            return(defaultDiscriminator);
        }
Exemplo n.º 3
0
        public static EdmProperty RemoveDefaultDiscriminatorCondition(
            this MappingFragment entityTypeMappingFragment)
        {
            DebugCheck.NotNull(entityTypeMappingFragment);

            var discriminatorColumn = entityTypeMappingFragment.GetDefaultDiscriminator();

            if (discriminatorColumn != null &&
                entityTypeMappingFragment.ColumnConditions.Any())
            {
                Debug.Assert(entityTypeMappingFragment.ColumnConditions.Count() == 1);

                entityTypeMappingFragment.ClearConditions();
            }

            entityTypeMappingFragment.RemoveDefaultDiscriminatorAnnotation();

            return(discriminatorColumn);
        }