当前位置: 首页>>代码示例>>C#>>正文


C# Edm.EntityType类代码示例

本文整理汇总了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;
            }
        }
开发者ID:davidebbo-test,项目名称:DynamicDataWCFDataService,代码行数:29,代码来源:EdmColumnProvider.cs

示例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.");
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:35,代码来源:SerializableImplementor.cs

示例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;
 }
开发者ID:mbsky,项目名称:myextensions,代码行数:25,代码来源:EntityHelper.cs

示例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);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:29,代码来源:EFTableProvider.cs

示例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);
        }
开发者ID:davidebbo-test,项目名称:DynamicDataWCFDataService,代码行数:25,代码来源:EdmTableProvider.cs

示例6: CreateNodeFactoryForEntity

        private INodeFactory CreateNodeFactoryForEntity(EntityType entity)
        {
            var type = MetadataHelpers.FindQualifiedTypeForEntity(entity);

            var factory = CreateClosedGenericNodeFactory(type);
            return factory;
        }
开发者ID:modulexcite,项目名称:EntityShell,代码行数:7,代码来源:RootNodeFactory.cs

示例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();
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:12,代码来源:RefType.cs

示例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;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:EFColumnProvider.cs

示例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;
 }
开发者ID:KCL5South,项目名称:KCLTextTemplating,代码行数:11,代码来源:CodeGenerationTools.cs

示例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);
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:EntityRecordInfo.cs

示例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);
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:9,代码来源:EntityRecordInfo.cs

示例13: DataContractImplementor

        internal DataContractImplementor(EntityType ospaceEntityType)
        {
            _baseClrType = ospaceEntityType.ClrType;

            var attributes = (DataContractAttribute[])_baseClrType.GetCustomAttributes(typeof(DataContractAttribute), false);
            if (attributes.Length > 0)
            {
                _dataContract = attributes[0];
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:DataContractImplementor.cs

示例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;
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:ExtentKey.cs

示例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;
            }
        }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:54,代码来源:IPOCOImplementor.cs


注:本文中的System.Data.Metadata.Edm.EntityType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。