本文整理汇总了C#中System.Data.Metadata.Edm.EntityType类的典型用法代码示例。如果您正苦于以下问题:C# EntityType类的具体用法?C# EntityType怎么用?C# EntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityType类属于System.Data.Metadata.Edm命名空间,在下文中一共展示了EntityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EdmColumnProvider
public EdmColumnProvider(EntityType entityType, EdmTableProvider table, EdmMember m, bool isPrimaryKey, bool supportPagingAndSorting)
: base(table)
{
EdmMember = m;
IsPrimaryKey = isPrimaryKey;
_table = table;
_supportSorting = supportPagingAndSorting;
MaxLength = 0;
Name = EdmMember.Name;
// REVIEW Seems like extra properties added in partial classes are not even detected by the metadata engine
IsCustomProperty = false;
// REVIEW: This should probably be a debug assert or we should only pass an EmdProperty
var property = EdmMember as EdmProperty;
if (property != null) {
IsForeignKeyComponent = DetermineIsForeignKeyComponent(property);
IsGenerated = IsServerGenerated(property);
}
ProcessFacets();
var navProp = m as NavigationProperty;
if (navProp != null) {
_isAssociation = true;
long key = EdmAssociationProvider.BuildRelationshipKey(entityType, navProp.FromEndMember);
((EdmDataModelProvider)table.DataModel).RelationshipEndLookup[key] = this;
}
}
示例2: 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.");
}
}
示例3: TryGetEntityType
public static bool TryGetEntityType(ObjectContext context, Type clrType, out EntityType entityType)
{
entityType = null;
if (context == null)
{
throw new ArgumentNullException("context");
}
if (clrType == null)
{
throw new ArgumentNullException("clrType");
}
EdmType type = null;
bool flag = context.MetadataWorkspace.TryGetType(clrType.Name, clrType.Namespace, DataSpace.OSpace, out type);
if (!flag)
{
LoadAssemblyIntoWorkspace(context.MetadataWorkspace, clrType.Assembly);
flag = context.MetadataWorkspace.TryGetType(clrType.Name, clrType.Namespace, DataSpace.OSpace, out type);
}
if (flag)
{
entityType = (EntityType)context.MetadataWorkspace.GetEdmSpaceType((StructuralType)type);
return true;
}
return false;
}
示例4: EFTableProvider
public EFTableProvider(EFDataModelProvider dataModel, EntitySet entitySet, EntityType entityType,
Type entityClrType, Type parentEntityClrType, Type rootEntityClrType, string name)
: base(dataModel) {
EntityType = entityClrType;
Name = name;
DataContextPropertyName = entitySet.Name;
ParentEntityType = parentEntityClrType;
RootEntityType = rootEntityClrType;
var genericMethod = DataModel.ContextType.GetMethod("CreateQuery");
CreateQueryMethod = genericMethod.MakeGenericMethod(EntityType);
CreateQueryString = CreateEntitySqlQueryString(entitySet);
var keyMembers = entityType.KeyMembers;
// columns (entity properties)
// note 1: keys are also available through es.ElementType.KeyMembers
// note 2: this includes "nav properties", kind of fancy, two-way relationship objects
var columns = new List<ColumnProvider>();
foreach (EdmMember m in entityType.Members) {
if (EFColumnProvider.IsSupportedEdmMemberType(m) && IsPublicProperty(entityClrType, m.Name)) {
EFColumnProvider entityMember = new EFColumnProvider(entityType, this, m, keyMembers.Contains(m));
columns.Add(entityMember);
}
}
_roColumns = new ReadOnlyCollection<ColumnProvider>(columns);
}
示例5: EdmTableProvider
public EdmTableProvider(EdmDataModelProvider dataModel, EntitySet entitySet, EntityType entityType, string name,
bool isReadonly, bool supportPagingAndSorting)
: base(dataModel)
{
_isReadonly = isReadonly;
SupportPaging = supportPagingAndSorting;
Name = name;
DataContextPropertyName = entitySet.Name;
EdmEntityType = entityType;
var keyMembers = entityType.KeyMembers;
// columns (entity properties)
// note 1: keys are also available through es.ElementType.KeyMembers
// note 2: this includes "nav properties", kind of fancy, two-way relationship objects
var columns = new List<ColumnProvider>();
foreach (EdmMember m in entityType.Members) {
if (EdmColumnProvider.IsSupportedEdmMemberType(m)) {
var entityMember = new EdmColumnProvider(entityType, this, m, keyMembers.Contains(m), supportPagingAndSorting);
columns.Add(entityMember);
}
}
_roColumns = new ReadOnlyCollection<ColumnProvider>(columns);
}
示例6: CreateNodeFactoryForEntity
private INodeFactory CreateNodeFactoryForEntity(EntityType entity)
{
var type = MetadataHelpers.FindQualifiedTypeForEntity(entity);
var factory = CreateClosedGenericNodeFactory(type);
return factory;
}
示例7: GetGenerationOption
public string GetGenerationOption(EdmProperty property, EntityType entity)
{
string result = "";
bool isPk = entity.KeyMembers.Contains(property);
MetadataProperty storeGeneratedPatternProperty = null;
string storeGeneratedPatternPropertyValue = "None";
if (property.MetadataProperties.TryGetValue(MetadataConstants.EDM_ANNOTATION_09_02 + ":StoreGeneratedPattern", false, out storeGeneratedPatternProperty))
storeGeneratedPatternPropertyValue = storeGeneratedPatternProperty.Value.ToString();
PrimitiveType edmType = (PrimitiveType)property.TypeUsage.EdmType;
if (edmType == null && property.TypeUsage.EdmType is EnumType)
{
EnumType enumType = property.TypeUsage.EdmType as EnumType;
edmType = enumType.UnderlyingType;
}
if (storeGeneratedPatternPropertyValue == "Computed")
{
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Computed))";
}
else if ((edmType.ClrEquivalentType == typeof(int)) || (edmType.ClrEquivalentType == typeof(short)) || (edmType.ClrEquivalentType == typeof(long)))
{
if (isPk && (storeGeneratedPatternPropertyValue != "Identity"))
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.None))";
else if ((!isPk || (entity.KeyMembers.Count > 1)) && (storeGeneratedPatternPropertyValue == "Identity"))
result = ".HasDatabaseGeneratedOption(new Nullable<DatabaseGeneratedOption>(DatabaseGeneratedOption.Identity))";
}
return result;
}
开发者ID:jradxl,项目名称:Entity-Framework-Code-Generation-Tools-Experiments,代码行数:29,代码来源:EF5DbContextFluentMappingLibrary.cs
示例8: RefType
/// <summary>
/// The constructor for constructing a RefType object with the entity type it references
/// </summary>
/// <param name="entityType">The entity type that this ref type references</param>
/// <exception cref="System.ArgumentNullException">Thrown if entityType argument is null</exception>
internal RefType(EntityType entityType)
: base(GetIdentity(EntityUtil.GenericCheckArgumentNull(entityType, "entityType")),
EdmConstants.TransientNamespace, entityType.DataSpace)
{
_elementType = entityType;
SetReadOnly();
}
示例9: EFColumnProvider
public EFColumnProvider(EntityType entityType, EFTableProvider table, EdmMember m, bool isPrimaryKey)
: base(table) {
EdmMember = m;
IsPrimaryKey = isPrimaryKey;
_table = table;
MaxLength = 0;
Name = EdmMember.Name;
//
IsCustomProperty = false;
//
var property = EdmMember as EdmProperty;
if (property != null) {
IsForeignKeyComponent = DetermineIsForeignKeyComponent(property);
IsGenerated = IsServerGenerated(property);
}
ProcessFacets();
var navProp = m as NavigationProperty;
if (navProp != null) {
_isAssociation = true;
long key = EFAssociationProvider.BuildRelationshipKey(entityType, navProp.FromEndMember);
((EFDataModelProvider)table.DataModel).RelationshipEndLookup[key] = this;
}
}
示例10: AbstractOption
/// <summary>
/// Returns the abstract option if the entity is Abstract, otherwise returns String.Empty
/// </summary>
public string AbstractOption(EntityType entity)
{
if (entity.Abstract)
{
return "abstract";
}
return String.Empty;
}
示例11: EntityRecordInfo
/// <summary>
///
/// </summary>
/// <param name="metadata"></param>
/// <param name="memberInfo"></param>
/// <param name="entityKey"></param>
public EntityRecordInfo(EntityType metadata, IEnumerable<EdmMember> memberInfo, EntityKey entityKey, EntitySet entitySet)
: base(TypeUsage.Create(metadata), memberInfo) {
EntityUtil.CheckArgumentNull<EntityKey>(entityKey, "entityKey");
EntityUtil.CheckArgumentNull(entitySet, "entitySet");
_entityKey = entityKey;
_entitySet = entitySet;
ValidateEntityType(entitySet);
}
示例12: EntityRecordInfo
public EntityRecordInfo(EntityType metadata, IEnumerable<EdmMember> memberInfo, EntityKey entityKey, EntitySet entitySet)
: base(TypeUsage.Create(metadata), memberInfo)
{
//Contract.Requires(entityKey != null);
//Contract.Requires(entitySet != null);
_entityKey = entityKey;
ValidateEntityType(entitySet);
}
示例13: DataContractImplementor
internal DataContractImplementor(EntityType ospaceEntityType)
{
_baseClrType = ospaceEntityType.ClrType;
var attributes = (DataContractAttribute[])_baseClrType.GetCustomAttributes(typeof(DataContractAttribute), false);
if (attributes.Length > 0)
{
_dataContract = attributes[0];
}
}
示例14: GetKeysForEntityType
// effects: Determines all the keys (unique and primary for
// entityType) for entityType and returns a key. "prefix" gives the
// path of the extent or end of a relationship in a relationship set
// -- prefix is prepended to the entity's key fields to get the full memberpath
internal static List<ExtentKey> GetKeysForEntityType(MemberPath prefix, EntityType entityType)
{
// CHANGE_ADYA_MULTIPLE_KEYS: currently there is a single key only. Need to support
// keys inside complex types + unique keys
var key = GetPrimaryKeyForEntityType(prefix, entityType);
var keys = new List<ExtentKey>();
keys.Add(key);
return keys;
}
示例15: CheckType
private void CheckType(EntityType ospaceEntityType)
{
_scalarMembers = new HashSet<EdmMember>();
_relationshipMembers = new HashSet<EdmMember>();
foreach (var member in ospaceEntityType.Members)
{
var clrProperty = EntityUtil.GetTopProperty(ospaceEntityType.ClrType, member.Name);
if (clrProperty != null
&& EntityProxyFactory.CanProxySetter(clrProperty))
{
if (member.BuiltInTypeKind
== BuiltInTypeKind.EdmProperty)
{
if (_implementIEntityWithChangeTracker)
{
_scalarMembers.Add(member);
}
}
else if (member.BuiltInTypeKind
== BuiltInTypeKind.NavigationProperty)
{
if (_implementIEntityWithRelationships)
{
var navProperty = (NavigationProperty)member;
var multiplicity = navProperty.ToEndMember.RelationshipMultiplicity;
if (multiplicity == RelationshipMultiplicity.Many)
{
if (clrProperty.PropertyType.IsGenericType
&&
clrProperty.PropertyType.GetGenericTypeDefinition() == typeof(ICollection<>))
{
_relationshipMembers.Add(member);
}
}
else
{
_relationshipMembers.Add(member);
}
}
}
}
}
if (ospaceEntityType.Members.Count
!= _scalarMembers.Count + _relationshipMembers.Count)
{
_scalarMembers.Clear();
_relationshipMembers.Clear();
_implementIEntityWithChangeTracker = false;
_implementIEntityWithRelationships = false;
}
}