本文整理汇总了C#中System.Data.Entity.Edm.EdmEntityType.GetDeclaredPrimitiveProperty方法的典型用法代码示例。如果您正苦于以下问题:C# EdmEntityType.GetDeclaredPrimitiveProperty方法的具体用法?C# EdmEntityType.GetDeclaredPrimitiveProperty怎么用?C# EdmEntityType.GetDeclaredPrimitiveProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Edm.EdmEntityType
的用法示例。
在下文中一共展示了EdmEntityType.GetDeclaredPrimitiveProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map_should_set_correct_name_and_type
public void Map_should_set_correct_name_and_type()
{
var entityType = new EdmEntityType();
var mappingContext
= new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), new EdmModel().Initialize());
new PropertyMapper(new TypeMapper(mappingContext))
.Map(new MockPropertyInfo(typeof(int), "Foo"), entityType, () => new EntityTypeConfiguration(typeof(object)));
Assert.Equal(1, entityType.DeclaredProperties.Count);
var property = entityType.GetDeclaredPrimitiveProperty("Foo");
Assert.Equal(EdmPrimitiveType.Int32, property.PropertyType.PrimitiveType);
}
示例2: ConfigureKey
private void ConfigureKey(EdmEntityType entityType)
{
Contract.Requires(entityType != null);
if (!_keyProperties.Any())
{
return;
}
if (entityType.BaseType != null)
{
throw Error.KeyRegisteredOnDerivedType(ClrType, entityType.GetRootType().GetClrType());
}
var keyProperties = _keyProperties.AsEnumerable();
if (!_isKeyConfigured)
{
var primaryKeys
= from p in _keyProperties
select new
{
PropertyInfo = p,
Property(new PropertyPath(p)).ColumnOrder
};
if ((_keyProperties.Count > 1)
&& primaryKeys.Any(p => !p.ColumnOrder.HasValue))
{
throw Error.ModelGeneration_UnableToDetermineKeyOrder(ClrType);
}
keyProperties = primaryKeys.OrderBy(p => p.ColumnOrder).Select(p => p.PropertyInfo);
}
foreach (var keyProperty in keyProperties)
{
var property = entityType.GetDeclaredPrimitiveProperty(keyProperty);
if (property == null)
{
throw Error.KeyPropertyNotFound(keyProperty.Name, entityType.Name);
}
property.PropertyType.IsNullable = false;
entityType.DeclaredKeyProperties.Add(property);
}
}
示例3: Configure_should_configure_and_order_keys_when_keys_and_order_specified
public void Configure_should_configure_and_order_keys_when_keys_and_order_specified()
{
var entityType = new EdmEntityType { Name = "E" };
entityType.AddPrimitiveProperty("P2").PropertyType.EdmType = EdmPrimitiveType.Int32;
entityType.AddPrimitiveProperty("P1").PropertyType.EdmType = EdmPrimitiveType.Int32;
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyInfo2 = new MockPropertyInfo(typeof(int), "P2");
entityTypeConfiguration.Key(mockPropertyInfo2);
entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo2)).ColumnOrder = 1;
entityType.GetDeclaredPrimitiveProperty("P2").SetClrPropertyInfo(mockPropertyInfo2);
var mockPropertyInfo1 = new MockPropertyInfo(typeof(int), "P1");
entityTypeConfiguration.Key(mockPropertyInfo1);
entityTypeConfiguration.Property(new PropertyPath(mockPropertyInfo1)).ColumnOrder = 0;
entityType.GetDeclaredPrimitiveProperty("P1").SetClrPropertyInfo(mockPropertyInfo1);
entityTypeConfiguration.Configure(entityType, new EdmModel());
Assert.Equal(2, entityType.DeclaredKeyProperties.Count);
Assert.Equal("P1", entityType.DeclaredKeyProperties.First().Name);
}
示例4: GetPrimitiveProperty_should_return_correct_property
public void GetPrimitiveProperty_should_return_correct_property()
{
var entityType = new EdmEntityType();
var property = entityType.AddPrimitiveProperty("Foo");
property.PropertyType.EdmType = EdmPrimitiveType.Guid;
var foundProperty = entityType.GetDeclaredPrimitiveProperty("Foo");
Assert.NotNull(foundProperty);
Assert.Same(property, foundProperty);
}