本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.ComplexType类的典型用法代码示例。如果您正苦于以下问题:C# ComplexType类的具体用法?C# ComplexType怎么用?C# ComplexType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComplexType类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了ComplexType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
示例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);
}
示例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());
}
示例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)
{
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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));
}
示例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;
}
示例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));
}
示例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());
}
示例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));
}
示例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());
}