本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.ComplexType类的典型用法代码示例。如果您正苦于以下问题:C# ComplexType类的具体用法?C# ComplexType怎么用?C# ComplexType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComplexType类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了ComplexType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Generate_should_flatten_complex_properties_to_columns
public void Generate_should_flatten_complex_properties_to_columns()
{
var databaseMapping = CreateEmptyModel();
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var complexType = new ComplexType("C");
var property = EdmProperty.Primitive("P1", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
complexType.AddMember(property);
entityType.AddComplexProperty("C1", complexType);
var property1 = EdmProperty.Primitive("P2", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
entityType.AddMember(property1);
var entitySet = databaseMapping.Model.AddEntitySet("ESet", entityType);
var type = typeof(object);
entityType.Annotations.SetClrType(type);
new TableMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest).Generate(entityType, databaseMapping);
var entityTypeMappingFragment
= databaseMapping.GetEntitySetMapping(entitySet).EntityTypeMappings.Single().MappingFragments.Single();
Assert.Equal(2, entityTypeMappingFragment.ColumnMappings.Count());
Assert.Equal(2, entityTypeMappingFragment.Table.Properties.Count());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:26,代码来源:TableMappingGeneratorTests.cs
示例2: Can_create_with_valid_complex_type
public void Can_create_with_valid_complex_type()
{
var complexType = new ComplexType();
var complexTypeMapping = new ComplexTypeMapping(complexType);
Assert.Same(complexType, complexTypeMapping.ComplexType);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:ComplexTypeMappingTests.cs
示例3: Can_generate_scalar_and_complex_properties_when_update
public void Can_generate_scalar_and_complex_properties_when_update()
{
var functionParameterMappingGenerator
= new FunctionParameterMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest);
var property0 = new EdmProperty("P0");
var property1 = new EdmProperty("P1");
var property2 = new EdmProperty("P2");
property2.SetStoreGeneratedPattern(StoreGeneratedPattern.Computed);
property2.ConcurrencyMode = ConcurrencyMode.Fixed;
var complexType = new ComplexType("CT", "N", DataSpace.CSpace);
complexType.AddMember(property1);
var complexProperty = EdmProperty.CreateComplex("C", complexType);
var parameterBindings
= functionParameterMappingGenerator
.Generate(
ModificationOperator.Update,
new[] { property0, complexProperty, property2 },
new[]
{
new ColumnMappingBuilder(new EdmProperty("C0"), new[] { property0 }),
new ColumnMappingBuilder(new EdmProperty("C_P1"), new[] { complexProperty, property1 }),
new ColumnMappingBuilder(new EdmProperty("C2"), new[] { property2 })
},
new List<EdmProperty>(),
useOriginalValues: true)
.ToList();
Assert.Equal(3, parameterBindings.Count());
var parameterBinding = parameterBindings.First();
Assert.Equal("C0", parameterBinding.Parameter.Name);
Assert.Same(property0, parameterBinding.MemberPath.Members.Single());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
parameterBinding = parameterBindings.ElementAt(1);
Assert.Equal("C_P1", parameterBinding.Parameter.Name);
Assert.Same(complexProperty, parameterBinding.MemberPath.Members.First());
Assert.Same(property1, parameterBinding.MemberPath.Members.Last());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
parameterBinding = parameterBindings.Last();
Assert.Equal("C2_Original", parameterBinding.Parameter.Name);
Assert.Same(property2, parameterBinding.MemberPath.Members.Single());
Assert.Equal("String", parameterBinding.Parameter.TypeName);
Assert.Equal(ParameterMode.In, parameterBinding.Parameter.Mode);
Assert.False(parameterBinding.IsCurrent);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:60,代码来源:FunctionParameterMappingGeneratorTests.cs
示例4: Configure_should_set_configuration
public void Configure_should_set_configuration()
{
var complexType = new ComplexType("C");
var complexTypeConfiguration = new ComplexTypeConfiguration(typeof(object));
complexTypeConfiguration.Configure(complexType);
Assert.Same(complexTypeConfiguration, complexType.GetConfiguration());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:9,代码来源:ComplexTypeConfigurationTests.cs
示例5: FunctionImportComplexTypeMapping
/// <summary>
/// Initializes a new FunctionImportComplexTypeMapping instance.
/// </summary>
/// <param name="returnType">The return type.</param>
/// <param name="properties">The property mappings for the result type of a function import.</param>
public FunctionImportComplexTypeMapping(
ComplexType returnType,
Collection<FunctionImportReturnTypePropertyMapping> properties)
: this(
Check.NotNull(returnType, "returnType"),
Check.NotNull(properties, "properties"),
LineInfo.Empty)
{
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:FunctionImportComplexTypeMapping.cs
示例6: IsComplexType_returns_true_when_complex_property
public void IsComplexType_returns_true_when_complex_property()
{
var complexType = new ComplexType();
var property = EdmProperty.CreateComplex("P", complexType);
Assert.False(property.IsPrimitiveType);
Assert.False(property.IsEnumType);
Assert.True(property.IsComplexType);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:10,代码来源:EdmPropertyTests.cs
示例7: Complex_should_create_complex_property
public void Complex_should_create_complex_property()
{
var complexType = new ComplexType();
var property = EdmProperty.CreateComplex("P", complexType);
Assert.NotNull(property);
Assert.NotNull(property.TypeUsage);
Assert.Same(complexType, property.TypeUsage.EdmType);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:10,代码来源:EdmPropertyTests.cs
示例8: GetClrType_returns_CLR_type_annotation_for_ComplexType
public void GetClrType_returns_CLR_type_annotation_for_ComplexType()
{
var complexType = new ComplexType("C", "N", DataSpace.CSpace);
Assert.Null(((EdmType)complexType).GetClrType());
complexType.Annotations.SetClrType(typeof(Random));
Assert.Same(typeof(Random), ((EdmType)complexType).GetClrType());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:10,代码来源:EdmTypeExtensionsTests.cs
示例9: Configure_should_throw_when_property_not_found
public void Configure_should_throw_when_property_not_found()
{
var complexType = new ComplexType("C");
var complexTypeConfiguration = new ComplexTypeConfiguration(typeof(object));
var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
complexTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);
Assert.Equal(
Strings.PropertyNotFound(("P"), "C"),
Assert.Throws<InvalidOperationException>(() => complexTypeConfiguration.Configure(complexType)).Message);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:ComplexTypeConfigurationTests.cs
示例10: AddComplexProperty_should_create_and_add_complex_property
public void AddComplexProperty_should_create_and_add_complex_property()
{
var complexType = new ComplexType("C");
var complexTypeProperty = new ComplexType("D");
var property = complexType.AddComplexProperty("Foo", complexTypeProperty);
Assert.NotNull(property);
Assert.Equal("Foo", property.Name);
Assert.Same(complexTypeProperty, property.ComplexType);
Assert.True(complexType.Properties.Contains(property));
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:ComplexTypeExtensionsTests.cs
示例11: Complex
public static EdmProperty Complex(string name, ComplexType complexType)
{
Check.NotEmpty(name, "name");
Check.NotNull(complexType, "complexType");
var property = CreateProperty(name, complexType);
property.Nullable = false;
return property;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:11,代码来源:EdmProperty.cs
示例12: AddPrimitiveProperty_should_create_and_add_to_primitive_properties
public void AddPrimitiveProperty_should_create_and_add_to_primitive_properties()
{
var complexType = new ComplexType("C");
var property1 = EdmProperty.CreatePrimitive("Foo", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
complexType.AddMember(property1);
var property = property1;
Assert.NotNull(property);
Assert.Equal("Foo", property.Name);
Assert.True(complexType.Properties.Contains(property));
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:ComplexTypeExtensionsTests.cs
示例13: Should_be_able_to_get_and_set_clr_type
public void Should_be_able_to_get_and_set_clr_type()
{
var complexType = new ComplexType("C");
Assert.Null(complexType.GetClrType());
var type = typeof(object);
complexType.Annotations.SetClrType(type);
Assert.Equal(typeof(object), complexType.GetClrType());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:ComplexTypeExtensionsTests.cs
示例14: AddComplexProperty_should_create_and_add_complex_property
public void AddComplexProperty_should_create_and_add_complex_property()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var complexType = new ComplexType("C");
var property = entityType.AddComplexProperty("Foo", complexType);
Assert.NotNull(property);
Assert.Equal("Foo", property.Name);
Assert.Same(complexType, property.ComplexType);
Assert.True(entityType.DeclaredProperties.Contains(property));
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:EntityTypeExtensionsTests.cs
示例15: Should_be_able_to_get_and_set_clr_type
public void Should_be_able_to_get_and_set_clr_type()
{
var complexType = new ComplexType("C");
Assert.Null(complexType.GetClrType());
var type = typeof(object);
complexType.GetMetadataProperties().SetClrType(type);
Assert.Equal(typeof(object), complexType.GetClrType());
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:ComplexTypeExtensionsTests.cs
示例16: Properties_list_should_be_live_on_reread
public void Properties_list_should_be_live_on_reread()
{
var complexType = new ComplexType("C");
Assert.Empty(complexType.Properties);
var property = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
complexType.AddMember(property);
Assert.Equal(1, complexType.Properties.Count);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:ComplexTypeTests.cs
示例17: GetPrimitiveProperty_should_return_correct_property
public void GetPrimitiveProperty_should_return_correct_property()
{
var complexType = new ComplexType("C");
var property1 = EdmProperty.CreatePrimitive("Foo", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));
complexType.AddMember(property1);
var property = property1;
var foundProperty = complexType.Properties.SingleOrDefault(p => p.Name == "Foo");
Assert.NotNull(foundProperty);
Assert.Same(property, foundProperty);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:ComplexTypeExtensionsTests.cs
示例18: AddComplexProperty
public static EdmProperty AddComplexProperty(
this ComplexType complexType, string name, ComplexType targetComplexType)
{
DebugCheck.NotNull(complexType);
DebugCheck.NotNull(complexType.Properties);
DebugCheck.NotEmpty(name);
DebugCheck.NotNull(targetComplexType);
var property = EdmProperty.CreateComplex(name, targetComplexType);
complexType.AddMember(property);
return property;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:ComplexTypeExtensions.cs
示例19: Cannot_add_property_when_read_only
public void Cannot_add_property_when_read_only()
{
var complexType = new ComplexType();
var complexTypeMapping = new ComplexTypeMapping(complexType);
complexTypeMapping.SetReadOnly();
var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));
Assert.Equal(
Strings.OperationOnReadOnlyItem,
Assert.Throws<InvalidOperationException>(
() => complexTypeMapping.AddPropertyMapping(scalarPropertyMapping)).Message);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:ComplexTypeMappingTests.cs
示例20: Map
public void Map(
PropertyInfo propertyInfo, ComplexType complexType,
Func<ComplexTypeConfiguration> complexTypeConfiguration)
{
DebugCheck.NotNull(propertyInfo);
DebugCheck.NotNull(complexType);
var property = MapPrimitiveOrComplexOrEnumProperty(
propertyInfo, complexTypeConfiguration, discoverComplexTypes: true);
if (property != null)
{
complexType.AddMember(property);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:15,代码来源:PropertyMapper.cs
注:本文中的System.Data.Entity.Core.Metadata.Edm.ComplexType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论