当前位置: 首页>>代码示例>>C#>>正文


C# Edm.EdmEntityType类代码示例

本文整理汇总了C#中System.Data.Entity.Edm.EdmEntityType的典型用法代码示例。如果您正苦于以下问题:C# EdmEntityType类的具体用法?C# EdmEntityType怎么用?C# EdmEntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EdmEntityType类属于System.Data.Entity.Edm命名空间,在下文中一共展示了EdmEntityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddEntityTypeMappingFragment

        public void AddEntityTypeMappingFragment(
            EdmEntitySet entitySet, EdmEntityType entityType, DbEntityTypeMappingFragment fragment)
        {
            Contract.Assert(fragment.Table == Table);

            _entityTypes.Add(entitySet, entityType);

            var defaultDiscriminatorColumn = fragment.GetDefaultDiscriminator();
            DbColumnCondition defaultDiscriminatorCondition = null;
            if (defaultDiscriminatorColumn != null)
            {
                defaultDiscriminatorCondition =
                    fragment.ColumnConditions.SingleOrDefault(cc => cc.Column == defaultDiscriminatorColumn);
            }

            foreach (var pm in fragment.PropertyMappings)
            {
                var columnMapping = FindOrCreateColumnMapping(pm.Column);
                columnMapping.AddMapping(
                    entityType,
                    pm.PropertyPath,
                    fragment.ColumnConditions.Where(cc => cc.Column == pm.Column),
                    defaultDiscriminatorColumn == pm.Column);
            }

            // Add any column conditions that aren't mapped to properties
            foreach (
                var cc in
                    fragment.ColumnConditions.Where(cc => !fragment.PropertyMappings.Any(pm => pm.Column == cc.Column)))
            {
                var columnMapping = FindOrCreateColumnMapping(cc.Column);
                columnMapping.AddMapping(entityType, null, new[] { cc }, defaultDiscriminatorColumn == cc.Column);
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:34,代码来源:TableMapping.cs

示例2: SetKeyNamesType

        public static void SetKeyNamesType(this DbTableMetadata table, EdmEntityType entityType)
        {
            //Contract.Requires(table != null);
            //Contract.Requires(entityType != null);

            table.Annotations.SetAnnotation(KeyNamesTypeAnnotation, entityType);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbTableMetadataExtensions.cs

示例3: Add

        public void Add(EdmEntitySet entitySet, EdmEntityType entityType)
        {
            Contract.Requires(entitySet != null);
            Contract.Requires(entityType != null);

            var i = 0;

            List<EdmEntityType> entityTypes;
            if (!_entityTypes.TryGetValue(entitySet, out entityTypes))
            {
                entityTypes = new List<EdmEntityType>();
                _entityTypes.Add(entitySet, entityTypes);
            }

            for (; i < entityTypes.Count; i++)
            {
                if (entityTypes[i] == entityType)
                {
                    return;
                }
                else if (entityType.IsAncestorOf(entityTypes[i]))
                {
                    break;
                }
            }
            entityTypes.Insert(i, entityType);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:27,代码来源:SortedEntityTypeIndex.cs

示例4: Apply_should_move_declared_keys_head_of_declared_properties_list

        public void Apply_should_move_declared_keys_head_of_declared_properties_list()
        {
            var entityType = new EdmEntityType();
            entityType.SetClrType(typeof(SimpleEntity));
            entityType.AddPrimitiveProperty("StaticProperty");
            entityType.AddPrimitiveProperty("PrivateProperty");
            entityType.AddPrimitiveProperty("InheritedPropertyB");
            entityType.AddPrimitiveProperty("InheritedPropertyA");
            entityType.AddPrimitiveProperty("PropertyB");
            entityType.AddPrimitiveProperty("PropertyA");
            entityType.DeclaredKeyProperties.Add(
                entityType.AddPrimitiveProperty("Key"));

            ((IEdmConvention<EdmEntityType>)new DeclaredPropertyOrderingConvention())
                .Apply(entityType, new EdmModel());

            Assert.True(
                entityType.DeclaredProperties.Select(e => e.Name)
                    .SequenceEqual(
                        new[]
                            {
                                "Key", "PrivateProperty", "PropertyA", "PropertyB", "InheritedPropertyA", "InheritedPropertyB",
                                "StaticProperty"
                            }));
        }
开发者ID:junxy,项目名称:entityframework,代码行数:25,代码来源:DeclaredPropertyOrderingConventionTests.cs

示例5: Contains

        public bool Contains(EdmEntitySet entitySet, EdmEntityType entityType)
        {
            Contract.Requires(entitySet != null);
            Contract.Requires(entityType != null);

            List<EdmEntityType> setTypes;
            return _entityTypes.TryGetValue(entitySet, out setTypes) && setTypes.Contains(entityType);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:8,代码来源:SortedEntityTypeIndex.cs

示例6: Can_get_and_set_configuration_annotation

        public void Can_get_and_set_configuration_annotation()
        {
            var entityType = new EdmEntityType();

            entityType.SetConfiguration(42);

            Assert.Equal(42, entityType.GetConfiguration());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:8,代码来源:EdmEntityTypeExtensionsTests.cs

示例7: Configure_should_throw_when_property_not_found

        public void Configure_should_throw_when_property_not_found()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
            var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
            entityTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);

            Assert.Equal(Strings.PropertyNotFound(("P"), "E"), Assert.Throws<InvalidOperationException>(() => entityTypeConfiguration.Configure(entityType, new EdmModel())).Message);
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例8: Configure_should_set_configuration

        public void Configure_should_set_configuration()
        {
            var entityType = new EdmEntityType { Name = "E" };
            var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));

            entityTypeConfiguration.Configure(entityType, new EdmModel());

            Assert.Same(entityTypeConfiguration, entityType.GetConfiguration());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:9,代码来源:EntityTypeConfigurationTests.cs

示例9: Apply_should_ignore_non_primitive_type

        public void Apply_should_ignore_non_primitive_type()
        {
            var entityType = new EdmEntityType();
            var property = entityType.AddPrimitiveProperty("Id");

            ((IEdmConvention<EdmEntityType>)new IdKeyDiscoveryConvention()).Apply(entityType, new EdmModel());

            Assert.False(entityType.DeclaredKeyProperties.Contains(property));
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:9,代码来源:IdKeyDiscoveryConventionTests.cs

示例10: Apply_should_ignore_case

        public void Apply_should_ignore_case()
        {
            var entityType = new EdmEntityType { Name = "Foo" };
            var property = entityType.AddPrimitiveProperty("foOid");
            property.PropertyType.EdmType = EdmPrimitiveType.Int32;

            ((IEdmConvention<EdmEntityType>)new IdKeyDiscoveryConvention()).Apply(entityType, new EdmModel());

            Assert.True(entityType.DeclaredKeyProperties.Contains(property));
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:IdKeyDiscoveryConventionTests.cs

示例11: Apply_should_make_key_not_nullable

        public void Apply_should_make_key_not_nullable()
        {
            var entityType = new EdmEntityType();
            var property = entityType.AddPrimitiveProperty("Id");
            property.PropertyType.EdmType = EdmPrimitiveType.Int32;

            ((IEdmConvention<EdmEntityType>)new IdKeyDiscoveryConvention()).Apply(entityType, new EdmModel());

            Assert.False(property.PropertyType.IsNullable.Value);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:IdKeyDiscoveryConventionTests.cs

示例12: Apply_should_match_simple_id

        public void Apply_should_match_simple_id()
        {
            var entityType = new EdmEntityType();
            var property = entityType.AddPrimitiveProperty("Id");
            property.PropertyType.EdmType = EdmPrimitiveType.Int32;

            ((IEdmConvention<EdmEntityType>)new IdKeyDiscoveryConvention()).Apply(entityType, new EdmModel());

            Assert.True(entityType.DeclaredKeyProperties.Contains(property));
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:IdKeyDiscoveryConventionTests.cs

示例13: AddMapping

 public void AddMapping(
     EdmEntityType entityType,
     IList<EdmProperty> propertyPath,
     IEnumerable<DbColumnCondition> conditions,
     bool isDefaultDiscriminatorCondition)
 {
     _propertyMappings.Add(
         new PropertyMappingSpecification(
             entityType, propertyPath, conditions.ToList(), isDefaultDiscriminatorCondition));
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:ColumnMapping.cs

示例14: GetPrimitiveProperties_should_return_only_primitive_properties

        public void GetPrimitiveProperties_should_return_only_primitive_properties()
        {
            var entityType = new EdmEntityType();
            var property = entityType.AddPrimitiveProperty("Foo");
            property.PropertyType.EdmType = EdmPrimitiveType.DateTime;
            entityType.AddComplexProperty("Bar", new EdmComplexType());

            Assert.Equal(1, entityType.GetDeclaredPrimitiveProperties().Count());
            Assert.True(entityType.GetDeclaredPrimitiveProperties().Contains(property));
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:10,代码来源:EdmEntityTypeExtensionsTests.cs

示例15: Can_get_and_set_clr_type_annotation

        public void Can_get_and_set_clr_type_annotation()
        {
            var entityType = new EdmEntityType();

            Assert.Null(entityType.GetClrType());

            entityType.SetClrType(typeof(object));

            Assert.Equal(typeof(object), entityType.GetClrType());
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:10,代码来源:EdmEntityTypeExtensionsTests.cs


注:本文中的System.Data.Entity.Edm.EdmEntityType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。