Exemplo n.º 1
0
        /// <inheritdoc/>
        protected override void WriteDbDataTypeForString(SqlWriter writer, ColumnMetadata column)
        {
            var strattr = column.GetProperty <StringAttribute>();

            if (strattr == null)
            {
                WriteDbDataType(writer, typeof(string));
            }
            else
            {
                if (strattr.Length > 0)
                {
                    if (!strattr.IsFixed)
                    {
                        writer.Write("VAR");
                    }
                    writer.Write("CHAR(");
                    writer.Write(strattr.Length);
                    writer.Write(')');
                }
                else
                {
                    WriteDbDataType(writer, typeof(string));
                }
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override void WriteDbDataType(SqlWriter writer, ColumnMetadata column)
        {
            var identity = column.GetProperty <IdentityAttribute>();

            if (identity != null)
            {
                var type = column.Member.PropertyType;
                if (type == typeof(int) || type == typeof(int?))
                {
                    writer.Write("SERIAL");
                }
                else if (type == typeof(short) || type == typeof(short?))
                {
                    writer.Write("SMALLSERIAL");
                }
                else if (type == typeof(long) || type == typeof(long?))
                {
                    writer.Write("BIGSERIAL");
                }
                else
                {
                    base.WriteDbDataType(writer, column);
                }
            }
            else
            {
                base.WriteDbDataType(writer, column);
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override void WriteDbDataType(SqlWriter writer, ColumnMetadata column)
        {
            var computed = column.GetProperty <ComputedAttribute>();

            if (computed != null)
            {
                writer.Write(" AS ");
                writer.Write(computed.Expression);
                return;
            }
            base.WriteDbDataType(writer, column);
        }
Exemplo n.º 4
0
        //写入带精度的数据类型。
        private void WriteDbDataTypeForScale(SqlWriter writer, ColumnMetadata column, Type type, string name)
        {
            var precision = column.GetProperty <PrecisionAttribute>();

            if (precision != null)
            {
                writer.Write(name);
                writer.Write('(');
                writer.Write(precision.Scale);
                writer.Write(')');
            }
            else
            {
                WriteDbDataType(writer, type);
            }
        }