本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.EntityType类的典型用法代码示例。如果您正苦于以下问题:C# EntityType类的具体用法?C# EntityType怎么用?C# EntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityType类属于System.Data.Entity.Core.Metadata.Edm命名空间,在下文中一共展示了EntityType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SerializableImplementor
internal SerializableImplementor(EntityType ospaceEntityType)
{
_baseClrType = ospaceEntityType.ClrType;
_baseImplementsISerializable = _baseClrType.IsSerializable && typeof(ISerializable).IsAssignableFrom(_baseClrType);
if (_baseImplementsISerializable)
{
// Determine if interface implementation can be overridden.
// Fortunately, there's only one method to check.
var mapping = _baseClrType.GetInterfaceMap(typeof(ISerializable));
_getObjectDataMethod = mapping.TargetMethods[0];
// Members that implement interfaces must be public, unless they are explicitly implemented, in which case they are private and sealed (at least for C#).
var canOverrideMethod = (_getObjectDataMethod.IsVirtual && !_getObjectDataMethod.IsFinal) && _getObjectDataMethod.IsPublic;
if (canOverrideMethod)
{
// Determine if proxied type provides the special serialization constructor.
// In order for the proxy class to properly support ISerializable, this constructor must not be private.
_serializationConstructor =
_baseClrType.GetConstructor(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null);
_canOverride = _serializationConstructor != null
&&
(_serializationConstructor.IsPublic || _serializationConstructor.IsFamily
|| _serializationConstructor.IsFamilyOrAssembly);
}
Debug.Assert(
!(_canOverride && (_getObjectDataMethod == null || _serializationConstructor == null)),
"Both GetObjectData method and Serialization Constructor must be present when proxy overrides ISerializable implementation.");
}
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:35,代码来源:SerializableImplementor.cs
示例2: Cannot_create_with_null_argument
public void Cannot_create_with_null_argument()
{
var entityType = new EntityType("ET", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", "S", "T", "Q", entityType);
var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
var parameterBindings = Enumerable.Empty<ModificationFunctionParameterBinding>();
var rowsAffectedParameter = new FunctionParameter("rows_affected", new TypeUsage(), ParameterMode.Out);
var resultBindings = Enumerable.Empty<ModificationFunctionResultBinding>();
Assert.Equal(
"entitySet",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
null, entityType, function,
parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);
Assert.Equal(
"function",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
entitySet, entityType, null,
parameterBindings, rowsAffectedParameter, resultBindings)).ParamName);
Assert.Equal(
"parameterBindings",
Assert.Throws<ArgumentNullException>(
() => new ModificationFunctionMapping(
entitySet, entityType, function,
null, rowsAffectedParameter, resultBindings)).ParamName);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:30,代码来源:ModificationFunctionMappingTests.cs
示例3: RefType
internal RefType(EntityType entityType)
: base(GetIdentity(Check.NotNull(entityType, "entityType")),
EdmConstants.TransientNamespace, entityType.DataSpace)
{
_elementType = entityType;
SetReadOnly();
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:RefType.cs
示例4: AddEntityTypeMappingFragment
public void AddEntityTypeMappingFragment(
EntitySet entitySet, EntityType entityType, StorageMappingFragment fragment)
{
Debug.Assert(fragment.Table == Table);
_entityTypes.Add(entitySet, entityType);
var defaultDiscriminatorColumn = fragment.GetDefaultDiscriminator();
StorageConditionPropertyMapping defaultDiscriminatorCondition = null;
if (defaultDiscriminatorColumn != null)
{
defaultDiscriminatorCondition =
fragment.ColumnConditions.SingleOrDefault(cc => cc.ColumnProperty == defaultDiscriminatorColumn);
}
foreach (var pm in fragment.ColumnMappings)
{
var columnMapping = FindOrCreateColumnMapping(pm.ColumnProperty);
columnMapping.AddMapping(
entityType,
pm.PropertyPath,
fragment.ColumnConditions.Where(cc => cc.ColumnProperty == pm.ColumnProperty),
defaultDiscriminatorColumn == pm.ColumnProperty);
}
// Add any column conditions that aren't mapped to properties
foreach (
var cc in
fragment.ColumnConditions.Where(cc => !fragment.ColumnMappings.Any(pm => pm.ColumnProperty == cc.ColumnProperty)))
{
var columnMapping = FindOrCreateColumnMapping(cc.ColumnProperty);
columnMapping.AddMapping(entityType, null, new[] { cc }, defaultDiscriminatorColumn == cc.ColumnProperty);
}
}
开发者ID:jwanagel,项目名称:jjwtest,代码行数:34,代码来源:TableMapping.cs
示例5: SetKeyNamesType
public static void SetKeyNamesType(this EntityType table, EntityType entityType)
{
DebugCheck.NotNull(table);
DebugCheck.NotNull(entityType);
table.Annotations.SetAnnotation(KeyNamesTypeAnnotation, entityType);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:7,代码来源:EntityTypeExtensions.cs
示例6: Map_should_create_association_sets_for_associations
public void Map_should_create_association_sets_for_associations()
{
var modelConfiguration = new ModelConfiguration();
var model = new EdmModel().Initialize();
var entityType = new EntityType
{
Name = "Source"
};
model.AddEntitySet("Source", entityType);
var mappingContext = new MappingContext(modelConfiguration, new ConventionsConfiguration(), model);
new NavigationPropertyMapper(new TypeMapper(mappingContext))
.Map(
new MockPropertyInfo(new MockType("Target"), "Nav"), entityType,
() => new EntityTypeConfiguration(typeof(object)));
Assert.Equal(1, model.Containers.Single().AssociationSets.Count);
var associationSet = model.Containers.Single().AssociationSets.Single();
Assert.NotNull(associationSet);
Assert.NotNull(associationSet.ElementType);
Assert.Equal("Source_Nav", associationSet.Name);
}
开发者ID:jwanagel,项目名称:jjwtest,代码行数:25,代码来源:NavigationPropertyMapperTests.cs
示例7: Create_throws_argument_exception_when_called_with_invalid_arguments
public void Create_throws_argument_exception_when_called_with_invalid_arguments()
{
var entityType = new EntityType("Source", "Namespace", DataSpace.CSpace);
var refType = new RefType(entityType);
var metadataProperty =
new MetadataProperty(
"MetadataProperty",
TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)),
"value");
Assert.Throws<ArgumentException>(
() => AssociationEndMember.Create(
null,
refType,
RelationshipMultiplicity.Many,
OperationAction.Cascade,
new[] { metadataProperty }));
Assert.Throws<ArgumentException>(
() => AssociationEndMember.Create(
String.Empty,
refType,
RelationshipMultiplicity.Many,
OperationAction.Cascade,
new[] { metadataProperty }));
Assert.Throws<ArgumentNullException>(
() => AssociationEndMember.Create(
"AssociationEndMember",
null,
RelationshipMultiplicity.Many,
OperationAction.Cascade,
new[] { metadataProperty }));
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:AssociationEndMemberTests.cs
示例8: MatchKeyProperty
/// <inheritdoc/>
protected override IEnumerable<EdmProperty> MatchKeyProperty(
EntityType entityType, IEnumerable<EdmProperty> primitiveProperties)
{
Check.NotNull(entityType, "entityType");
Check.NotNull(primitiveProperties, "primitiveProperties");
var matches = primitiveProperties
.Where(p => Id.Equals(p.Name, StringComparison.OrdinalIgnoreCase));
if (!matches.Any())
{
matches = primitiveProperties
.Where(p => (entityType.Name + Id).Equals(p.Name, StringComparison.OrdinalIgnoreCase));
}
// If the number of matches is more than one, then multiple properties matched differing only by
// case--for example, "Id" and "ID". In such as case we throw and point the developer to using
// data annotations or the fluent API to disambiguate.
if (matches.Count() > 1)
{
throw Error.MultiplePropertiesMatchedAsKeys(matches.First().Name, entityType.Name);
}
return matches;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:26,代码来源:IdKeyDiscoveryConvention.cs
示例9: Can_retrieve_properties
public void Can_retrieve_properties()
{
var source = new EntityType("Source", "N", DataSpace.CSpace);
var target = new EntityType("Target", "N", DataSpace.CSpace);
var sourceEnd = new AssociationEndMember("SourceEnd", source);
var targetEnd = new AssociationEndMember("TargetEnd", target);
var associationType
= AssociationType.Create(
"AT",
"N",
true,
DataSpace.CSpace,
sourceEnd,
targetEnd,
null,
null);
var sourceSet = new EntitySet("SourceSet", "S", "T", "Q", source);
var targetSet = new EntitySet("TargetSet", "S", "T", "Q", target);
var associationSet
= AssociationSet.Create(
"AS",
associationType,
sourceSet,
targetSet,
null);
var members = new List<EdmMember> { null, targetEnd };
var memberPath = new ModificationFunctionMemberPath(members, associationSet);
Assert.Equal(members, memberPath.Members);
Assert.Equal(targetEnd.Name, memberPath.AssociationSetEnd.Name);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:32,代码来源:MidificationFunctionMemberPathTests.cs
示例10: LinqToEntitiesEntity
/// <summary>
/// Creates a new instance
/// </summary>
/// <param name="context">The linq to entities context owning this entity</param>
/// <param name="entityType">The entity type in the EDM model</param>
/// <param name="type">The CLR type of the entity</param>
public LinqToEntitiesEntity(LinqToEntitiesContextBase context, EntityType entityType, Type type)
: base(context, entityType.Name, type)
{
this._hasTimestampMember = entityType.Members.Where(p => ObjectContextUtilities.IsConcurrencyTimestamp(p)).Count() == 1;
this._entityType = entityType;
this._isDbContext = context is LinqToEntitiesDbContext;
}
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:13,代码来源:LinqToEntitiesEntity.cs
示例11: Create_factory_method_sets_properties_and_seals_the_type
public void Create_factory_method_sets_properties_and_seals_the_type()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet =
EntitySet.Create(
"EntitySet",
"dbo",
"tblEntities",
"definingQuery",
entityType,
new[]
{
new MetadataProperty(
"TestProperty",
TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)),
"value")
});
Assert.Equal("EntitySet", entitySet.Name);
Assert.Equal("dbo", entitySet.Schema);
Assert.Equal("tblEntities", entitySet.Table);
Assert.Equal("definingQuery", entitySet.DefiningQuery);
Assert.Same(entityType, entitySet.ElementType);
var metadataProperty = entitySet.MetadataProperties.SingleOrDefault(p => p.Name == "TestProperty");
Assert.NotNull(metadataProperty);
Assert.Equal("value", metadataProperty.Value);
Assert.True(entitySet.IsReadOnly);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:31,代码来源:EntitySetTests.cs
示例12: Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings
public void Can_not_create_composable_function_import_mapping_with_entity_set_and_null_structural_type_mappings()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", null, null, null, entityType);
var functionImport =
new EdmFunction(
"f",
"entityModel",
DataSpace.CSpace,
new EdmFunctionPayload
{
IsComposable = true,
EntitySets = new[] { entitySet },
ReturnParameters =
new[]
{
new FunctionParameter(
"ReturnType",
TypeUsage.CreateDefaultTypeUsage(entityType),
ParameterMode.ReturnValue)
}
});
Assert.Equal(
Strings.ComposableFunctionImportsReturningEntitiesNotSupported,
Assert.Throws<NotSupportedException>(
() => new FunctionImportMappingComposable(
functionImport,
new EdmFunction(
"f", "store", DataSpace.CSpace, new EdmFunctionPayload { IsComposable = true }),
null)).Message);
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:33,代码来源:FunctionImportMappingComposableTests.cs
示例13: SetOwner
public virtual void SetOwner(EntityType owner)
{
Util.ThrowIfReadOnly(this);
if (owner == null)
{
_database.RemoveAssociationType(_associationType);
}
else
{
_associationType.TargetEnd
= new AssociationEndMember(
owner != PrincipalTable ? owner.Name : owner.Name + SelfRefSuffix,
owner);
_associationSet.TargetSet
= _database.GetEntitySet(owner);
if (!_database.AssociationTypes.Contains(_associationType))
{
_database.AddAssociationType(_associationType);
_database.AddAssociationSet(_associationSet);
}
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:ForeignKeyBuilder.cs
示例14: IncludeColumn
public static EdmProperty IncludeColumn(
EntityType table, EdmProperty templateColumn, bool useExisting)
{
DebugCheck.NotNull(table);
DebugCheck.NotNull(templateColumn);
var existingColumn =
table.Properties.SingleOrDefault(c => string.Equals(c.Name, templateColumn.Name, StringComparison.Ordinal));
if (existingColumn == null)
{
templateColumn = templateColumn.Clone();
}
else if (!useExisting
&& !existingColumn.IsPrimaryKeyColumn)
{
templateColumn = templateColumn.Clone();
}
else
{
templateColumn = existingColumn;
}
AddColumn(table, templateColumn);
return templateColumn;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:27,代码来源:EntityMappingTransformer.cs
示例15: SetKeyNamesType
public static void SetKeyNamesType(this EntityType table, EntityType entityType)
{
DebugCheck.NotNull(table);
DebugCheck.NotNull(entityType);
table.GetMetadataProperties().SetAnnotation(KeyNamesTypeAnnotation, entityType);
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:7,代码来源:EntityTypeExtensions.cs
示例16: 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
示例17: Can_set_owner_and_corresponding_association_added_to_model
public void Can_set_owner_and_corresponding_association_added_to_model()
{
var database
= new EdmModel
{
Version = 3.0
}.DbInitialize();
var foreignKeyBuilder = new ForeignKeyBuilder(database, "FK");
var principalTable = new EntityType("P", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
foreignKeyBuilder.PrincipalTable = principalTable;
var dependentTable = new EntityType("D", XmlConstants.TargetNamespace_3, DataSpace.SSpace);
foreignKeyBuilder.SetOwner(dependentTable);
var associationType = database.GetAssociationType("FK");
Assert.NotNull(associationType);
Assert.NotNull(associationType.SourceEnd);
Assert.NotNull(associationType.TargetEnd);
Assert.Same(principalTable, associationType.SourceEnd.GetEntityType());
Assert.Equal("P", associationType.SourceEnd.Name);
Assert.Same(dependentTable, associationType.TargetEnd.GetEntityType());
Assert.Equal("D", associationType.TargetEnd.Name);
var associationSet = database.GetAssociationSet(associationType);
Assert.NotNull(associationSet);
}
开发者ID:jwanagel,项目名称:jjwtest,代码行数:31,代码来源:ForeignKeyBuilderTests.cs
示例18: Can_clear_modification_function_mappings
public void Can_clear_modification_function_mappings()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("S", "N", null, null, entityType);
var function = new EdmFunction("F", "N", DataSpace.SSpace, new EdmFunctionPayload());
var container = new EntityContainer("C", DataSpace.CSpace);
container.AddEntitySetBase(entitySet);
var entitySetMapping =
new StorageEntitySetMapping(
entitySet,
new StorageEntityContainerMapping(container));
var functionMapping =
new StorageModificationFunctionMapping(
entitySet,
entityType,
function,
Enumerable.Empty<StorageModificationFunctionParameterBinding>(),
null,
null);
var entityFunctionMappings =
new StorageEntityTypeModificationFunctionMapping(entityType, functionMapping, null, null);
entitySetMapping.AddModificationFunctionMapping(entityFunctionMappings);
Assert.Equal(1, entitySetMapping.ModificationFunctionMappings.Count());
entitySetMapping.ClearModificationFunctionMappings();
Assert.Equal(0, entitySetMapping.ModificationFunctionMappings.Count());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:34,代码来源:StorageEntitySetMappingTests.cs
示例19: AddEntityTypeMappingFragment
public void AddEntityTypeMappingFragment(
EntitySet entitySet, EntityType entityType, MappingFragment fragment)
{
Debug.Assert(fragment.Table == Table);
_entityTypes.Add(entitySet, entityType);
var defaultDiscriminatorColumn = fragment.GetDefaultDiscriminator();
foreach (var cm in fragment.ColumnMappings)
{
var columnMapping = FindOrCreateColumnMapping(cm.ColumnProperty);
columnMapping.AddMapping(
entityType,
cm.PropertyPath,
fragment.ColumnConditions.Where(cc => cc.Column == cm.ColumnProperty),
defaultDiscriminatorColumn == cm.ColumnProperty);
}
// Add any column conditions that aren't mapped to properties
foreach (
var cc in
fragment.ColumnConditions.Where(cc => fragment.ColumnMappings.All(pm => pm.ColumnProperty != cc.Column)))
{
var columnMapping = FindOrCreateColumnMapping(cc.Column);
columnMapping.AddMapping(entityType, null, new[] { cc }, defaultDiscriminatorColumn == cc.Column);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:28,代码来源:TableMapping.cs
示例20: GetDynamicModule
private static ModuleBuilder GetDynamicModule(EntityType ospaceEntityType)
{
var assembly = ospaceEntityType.ClrType.Assembly;
ModuleBuilder moduleBuilder;
if (!_moduleBuilders.TryGetValue(assembly, out moduleBuilder))
{
var assemblyName =
new AssemblyName(String.Format(CultureInfo.InvariantCulture, "EntityFrameworkDynamicProxies-{0}", assembly.FullName));
assemblyName.Version = new Version(1, 0, 0, 0);
var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName, s_ProxyAssemblyBuilderAccess);
if (s_ProxyAssemblyBuilderAccess == AssemblyBuilderAccess.RunAndSave)
{
// Make the module persistable if the AssemblyBuilderAccess is changed to be RunAndSave.
moduleBuilder = assemblyBuilder.DefineDynamicModule("EntityProxyModule", "EntityProxyModule.dll");
}
else
{
moduleBuilder = assemblyBuilder.DefineDynamicModule("EntityProxyModule");
}
_moduleBuilders.Add(assembly, moduleBuilder);
}
return moduleBuilder;
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:27,代码来源:EntityProxyFactory.cs
注:本文中的System.Data.Entity.Core.Metadata.Edm.EntityType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论