internal ColumnAttributeByMember GetColumnAttribute()
        {
            var columnAttribute = new Linq.Mapping.ColumnAttribute
            {
                Name      = columnName,
                CanBeNull = canBeNull ??
                            TypeSystem.IsNullableType(Property.PropertyType) || !Property.PropertyType.IsValueType,
                IsVersion = isConcurrencyToken ?? false
            };

            switch (databaseGeneratedOption)
            {
            case DatabaseGeneratedOption.Identity:
                columnAttribute.AutoSync      = AutoSync.OnInsert;
                columnAttribute.IsDbGenerated = true;
                break;

            case DatabaseGeneratedOption.Computed:
                columnAttribute.AutoSync      = AutoSync.Always;
                columnAttribute.IsDbGenerated = true;
                break;

            default:
                columnAttribute.AutoSync      = AutoSync.Never;
                columnAttribute.IsDbGenerated = false;
                break;
            }
            columnAttribute.DbType = BuildDbType(columnAttribute);
            return(new ColumnAttributeByMember
            {
                Member = Property,
                Attribute = columnAttribute
            });
        }
        private string BuildDbType(Linq.Mapping.ColumnAttribute columnAttribute)
        {
            if (columnAttribute == null)
            {
                throw new ArgumentNullException("columnAttribute");
            }

            var dbTypeWithoutNullability = BuildDbTypeWithoutNullability(columnAttribute);

            return(dbTypeWithoutNullability == null ?
                   null :
                   dbTypeWithoutNullability + (columnAttribute.CanBeNull ? " null" : " not null"));
        }
        protected virtual string BuildDbTypeWithoutNullability(Linq.Mapping.ColumnAttribute columnAttribute)
        {
            if (columnAttribute == null)
            {
                throw new ArgumentNullException("columnAttribute");
            }

            var dbType = GetEffectiveColumnType();

            if (databaseGeneratedOption == DatabaseGeneratedOption.Identity)
            {
                dbType += " identity";
            }
            return(dbType);
        }