Exemple #1
0
        /// <summary>
        /// Build the SQLite declaration statement for a table column.
        /// </summary>
        /// <param name="dc">Data column.</param>
        /// <returns>Declaration of the column.</returns>
        private static string buildColumnDeclarationAccessColumn(IAccessColumn col)
        {
            //Column name;
            string sql = string.Format("{0} ", col.ColumnName);

            //Determine the appropriate data type;
            Type dataType = col.Type;

            //Save the type;
            if (dataType == typeof(float) || dataType == typeof(double))
            {
                sql += "real";
            }
            else if (dataType == typeof(int))
            {
                sql += "int";
            }
            else
            {
                sql += "text";
            }

            //Default value;
            object defaultValue = col.DefaultValue;

            if (defaultValue != null)
            {
                sql += " default ";
                string sz = string.Empty;
                if (dataType != typeof(float) || dataType != typeof(double) || dataType != typeof(int))
                {
                    sz = "'";
                }
                sql += string.Format("{0}{1}{0}", sz, defaultValue);
            }

            //Return the declaration;
            return(sql);
        }
Exemple #2
0
        /// <summary>
        /// Build the SQLite declaration statement for a table column.
        /// </summary>
        /// <param name="dc">Data column.</param>
        /// <returns>Declaration of the column.</returns>
        private static string buildColumnDeclarationAccessColumn(IAccessColumn col)
        {
            //Column name;
            string sql = string.Format("{0} ", col.ColumnName);

            //Determine the appropriate data type;
            Type dataType = col.Type;

            //Save the type;
            if (dataType == typeof(float) || dataType == typeof(double))
                sql += "real";
            else if (dataType == typeof(int))
                sql += "int";
            else
                sql += "text";

            //Default value;
            object defaultValue = col.DefaultValue;
            if (defaultValue != null)
            {
                sql += " default ";
                string sz = string.Empty;
                if (dataType != typeof(float) || dataType != typeof(double) || dataType != typeof(int))
                    sz = "'";
                sql += string.Format("{0}{1}{0}", sz, defaultValue);
            }

            //Return the declaration;
            return sql;
        }