コード例 #1
0
        private PropertyType ResolvePropertyType()
        {
            PropertyType?type = null;

            // Concurrency
            if (!String.IsNullOrEmpty(PropertySource.ConcurrencyMode) && PropertySource.ConcurrencyMode.Equals(EdmxConstants.ConcurrencyModeFixed, StringComparison.OrdinalIgnoreCase))
            {
                type = PropertyType.Concurrency;
            }
            else if (Boolean.TrueString.Equals(PropertySource.GetAttributeValue(EdmxConstants.IsIndexCustomAttribute)))
            {
                type = PropertyType.Index;
            }

            //if (IsForeignKey) type &= Enums.PropertyType.Foreign;

            return(type ?? PropertyType.Normal);
        }
コード例 #2
0
        private PropertyType ResolvePropertyType()
        {
            PropertyType?type = null;

            var isPrimaryKey = Entity.HasKey && Entity.Key.Properties.Count(p => p.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)) > 0;

            if (isPrimaryKey)
            {
                type = PropertyType.Key;
            }

            // Concurrency
            if (!String.IsNullOrEmpty(PropertySource.ConcurrencyMode) && PropertySource.ConcurrencyMode.Equals(EdmxConstants.ConcurrencyModeFixed, StringComparison.OrdinalIgnoreCase))
            {
                if (!type.HasValue)
                {
                    type = PropertyType.Concurrency;
                }
                else
                {
                    type |= PropertyType.Concurrency;
                }
            }

            // http://msdn.microsoft.com/en-us/library/system.data.metadata.edm.storegeneratedpattern.aspx
            switch (PropertySource.StoreGeneratedPattern)
            {
            case EdmxConstants.StoreGeneratedPatternIdentity:
                if (!type.HasValue)
                {
                    type = PropertyType.Identity;
                }
                else
                {
                    type |= PropertyType.Identity;
                }
                break;

            case EdmxConstants.StoreGeneratedPatternComputed:
                if (!type.HasValue)
                {
                    type = PropertyType.Computed;
                }
                else
                {
                    type |= PropertyType.Computed;
                }
                break;

            case EdmxConstants.ConcurrencyModeNone:
                break;
            }

            // Check for index.
            if (Boolean.TrueString.Equals(PropertySource.GetAttributeValue(EdmxConstants.IsIndexCustomAttribute)))
            {
                if (!type.HasValue)
                {
                    type = PropertyType.Index;
                }
                else
                {
                    type |= PropertyType.Index;
                }
            }

            //if (IsForeignKey) type &= Enums.PropertyType.Foreign;

            return(type ?? PropertyType.Normal);
        }