Ejemplo n.º 1
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string db;
            string vers;

            using (DbCommand cmd = forDatabase.CreateCommand("SELECT sqlite_version()", CommandType.Text))
            {
                object versValue = forDatabase.ExecuteScalar(cmd);
                db   = cmd.Connection.Database;
                vers = (null == versValue) ? string.Empty : versValue.ToString();
            }

            string dbname = GetDataSourceNameFromConnection(forDatabase);
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBDatabaseProperties props = new DBDatabaseProperties(dbname, "SQLite", db, "", "@{0}", new Version(vers),
                                                                  SupportedSchemaOptions.TablesViewsAndIndexes | DBSchemaTypes.CommandScripts, false,
                                                                  DBParameterLayout.Named, SUPPORTED_TYPES, new TopType[] { TopType.Count, TopType.Range },
                                                                  Schema.DBSchemaInformation.CreateDefault(),
                                                                  unsupported);

            return(props);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Outputs the specified query as a SQL statement onto the console. User the DaBDatabase from CreateDB()
        /// </summary>
        /// <param name="query"></param>
        /// <param name="name"></param>
        private void OutputSql(DBQuery query, string name)
        {
            DBDatabase db = CreateDB();

            Console.WriteLine("SQL statement for :{0} ", name);
            Console.WriteLine();
            DbCommand cmd = db.CreateCommand(query);

            Console.WriteLine(cmd.CommandText);
            if (cmd.Parameters.Count > 0)
            {
                foreach (DbParameter p in cmd.Parameters)
                {
                    Console.WriteLine("Parameter '{0}': sourcename='{1}', type='{2}', size='{3}', direction='{4}', hasvalue='{5}';",
                                      p.ParameterName, p.SourceColumn, p.DbType, p.Size, p.Direction, (null != p.Value && ((p.Value is DBNull) == false)));
                }
            }
            Console.WriteLine();
        }
Ejemplo n.º 3
0
        private string OutputSql(DBDatabase db, DBQuery query, string name, bool output)
        {
            DbCommand cmd = db.CreateCommand(query);
            string    all = cmd.CommandText;

            if (cmd.Parameters.Count > 0)
            {
                foreach (DbParameter p in cmd.Parameters)
                {
                    string param = string.Format("Parameter '{0}': sourcename='{1}', type='{2}', size='{3}', direction='{4}', hasvalue='{5}';",
                                                 p.ParameterName, p.SourceColumn, p.DbType, p.Size, p.Direction, (null != p.Value && ((p.Value is DBNull) == false)));
                    all += "\r\n" + param;
                }
            }
            if (output)
            {
                Console.WriteLine("SQL statement for :{0} ", name);
                Console.WriteLine();
                Console.WriteLine(all);
            }
            return(all);
        }