/// <summary>解析表达式 /// </summary> public string EvalQuery(QueryWapper queryWapper) { Ensure.NotNull(queryWapper, "QueryWapper"); var builder = (MySqlQueryBuilder)SqlBuilderFactory.CreateQueryBuilder(SqlType.MySql, queryWapper); return(""); }
internal static string GetCreateTrigger(DbConnection con, string table, string triggerName) { string triggerCreateStatement = ""; string sql = ""; try { sql = new SqlBuilderFactory(con).Create(con.Database).GetTriggerCreateStatement(table, triggerName); using (var r = new DbCommandFactory(con, sql).Create().ExecuteReader()) { while (r.Read()) { if (con is MySqlConnection || con is SQLiteConnection) { triggerCreateStatement = "DELIMITER $ " + "\r\n" + r.GetString(2) + " $ " + "\r\n" + " DELIMITER ;\0"; } else { triggerCreateStatement = r.GetString(2); } break; } } } catch (DbException ex) { sql = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(sql); return(triggerCreateStatement); }
internal static DataTable GetDatabasePrimaryKeysDataSource(sqlservers server, DbConnection con) { DataTable data = new DataTable(); DataColumn c0 = new DataColumn("Column"); DataColumn c1 = new DataColumn("Table"); data.Columns.Add(c0); data.Columns.Add(c1); List <string> tables = DbDataHelper.getTables(con); foreach (string table in tables) { string table_info = new SqlBuilderFactory(server).Create(con.Database).describeTableSql(table); using (var r = new DbCommandFactory(con, table_info).Create().ExecuteReader()) { while (r.Read()) { if (r.GetInt32(5) >= 1) { DataRow row = data.NewRow(); row["Column"] = r.GetString(1); row["Table"] = table; data.Rows.Add(row); } } } } return(data); }
internal static List <string> getTableInfo(DbConnection con, string table) { var data = new List <string>(); if (!sql.Utils.IsDbEmbedded(sql.Utils.GetDbTypeEnum(con))) { string command = ""; try { command = new SqlBuilderFactory(con).Create(con.Database).getTableInfo(table); using (var reader = new DbCommandFactory(con, command).Create().ExecuteReader()) { while (reader.Read()) { data.Add("~Rows:" + (reader.IsDBNull(5) ? "" : reader.GetString(5))); data.Add("AvgLen:" + (reader.IsDBNull(0) ? "" : reader.GetString(0))); data.Add("Length:" + (reader.IsDBNull(1) ? "" : reader.GetString(1))); data.Add("Free:" + (reader.IsDBNull(2) ? "" : reader.GetString(2))); data.Add("AI:" + (reader.IsDBNull(3) ? "" : reader.GetString(3))); data.Add("Collation:" + (reader.IsDBNull(4) ? "" : reader.GetString(4))); } } } catch (DbException ex) { command = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(command); } return(data); }
public IList <T> SelectSchemaInfo <T>(InformationType infoType) { Logger.Info($"Selecting basic schema information of type: {infoType}"); var queryBuilder = SqlBuilderFactory.Create(DbType, Database.ConnectionString); Sql sqlQuery = queryBuilder.GetSqlQueryString(infoType); try { using (var db = Database) { Logger.Info($"Querying database with {sqlQuery}"); var queryResult = db.Query <T>(sqlQuery).ToList(); return(queryResult); } } catch (SqlException exception) { Logger.Warn(exception, $"Unable to retrieve basic schema information of type {infoType} from database."); return(null); } catch (Exception exception) { Logger.Warn(exception, "Unexpected error."); return(null); } }
internal static List <string> getTableTriggers(DbConnection con, string table) { var data = new List <string>(); string sql = ""; try { sql = new SqlBuilderFactory(con).Create(con.Database).GetTableTriggers(table); using (var reader = new DbCommandFactory(con, sql).Create().ExecuteReader()) { while (reader.Read()) { data.Add(reader.GetString(0)); } } } catch (DbException ex) { sql = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(sql); return(data); }
public static List <string> getTables(sqlservers server, string database, DbConnection con = null) { List <string> data = null; string sql = ""; try { if (con == null) { using (con = DB.connect(server, database)) { sql = new SqlBuilderFactory(con).Create(database).showTablesSql(); data = getStringData(con, sql); Terminal.MainTerminal.AppendText(sql); } return(data); } sql = new SqlBuilderFactory(con).Create(database).showTablesSql(); data = getStringData(con, sql); } catch (DbException ex) { sql = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(sql); return(data); }
internal static string getCreateTable(DbConnection con, string table) { string res = ""; string sql = ""; try { sql = new SqlBuilderFactory(con).Create(con.Database).ShowCreateStatement(table); using (var reader = new DbCommandFactory(con, sql).Create().ExecuteReader()) { while (reader.Read()) { res = reader.GetString(1); } } } catch (DbException ex) { sql = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(sql); return(res); }
private static Func <string> GetOperationDelegate(Type type, SqlOperation opr) { var modelType = type; if (type.IsArray) { modelType = type.GetElementType(); if (modelType == null) { throw new ArgumentException("Type GetElementType Null"); } } var key = modelType.FullName + opr; var @delegate = ModuleHandles.GetOrAdd(key, n => { var d = (Delegate)SqlBuilderFactory.Factory(modelType, opr); if (d == null) { throw new ArgumentException($"{n} delegate is null"); } return(d); }); var func = (Func <string>)@delegate; return(func); }
public void SelectTestWithJoins_WithTableNameSet(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { SqlAliasHelper.ClearAliases(); const string entityTableName = "EntityTable"; const string childTableName = "ChildEntityTable"; const string childChildTableName = "ChildChildEntityTable"; var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); var useSchema = !string.IsNullOrEmpty(schema); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId() ?? string.Empty); var builder = dbConfig.SqlBuilder(); var select = builder.Select(); var sqls = new List <string> { @select .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .From <Entity>(entityTableName) .InnerJoin <Entity, ChildEntity>(fromTableName: entityTableName, toTableName: childTableName) .LeftOuterJoin <ChildEntity, ChildChildEntity>(fromTableName: childTableName, toTableName: childChildTableName) .Fields <ChildEntity>(x => x.F(item => item.Description)) .Fields <ChildEntity>(x => x.F(item => item.Relation)) .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .Where <Entity>(x => x.WV(item => item.Name, "Arild")) .Build(), @select .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .From <Entity>(entityTableName) .Fields <ChildEntity>(x => x.F(item => item.Description)) .Fields <ChildEntity>(x => x.F(item => item.Relation)) .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .InnerJoin <Entity, ChildEntity>(fromTableName: entityTableName, toTableName: childTableName) .LeftOuterJoin <ChildEntity, ChildChildEntity>(fromTableName: childTableName, toTableName: childChildTableName) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .Where <Entity>(x => x.WV(item => item.Name, "Arild")) .Build(), @select .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .InnerJoin <Entity, ChildEntity>(fromTableName: entityTableName, toTableName: childTableName) .LeftOuterJoin <ChildEntity, ChildChildEntity>(fromTableName: childTableName, toTableName: childChildTableName) .Fields <ChildEntity>(x => x.F(item => item.Description)) .Fields <ChildEntity>(x => x.F(item => item.Relation)) .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .Where <Entity>(x => x.WV(item => item.Name, "Arild")) .Build(), }; foreach (var sql in sqls) { sql.Should().Be(expectedSql); } }
private void setDatagridviewTables() { SqlBuilderFactory sqlFactory = new SqlBuilderFactory(GetServer()); ISqlBuilder sqlBuilder = sqlFactory.Create(GetSqlConnection().Database); dataGridViewTables.DataSource = DbUtils.getDataTableData(GetSqlConnection(), sqlBuilder.getDatabaseTables()); }
public BultinSqlBuilderTest(ProviderStateApiFactory <Startup> factory) : base(factory, "http://localhost:5001/api/v1") { var connectionString = Config.Instance().GetConnectionString(); var connection = ConnectionFactory.NewConnection <SqlServerConnectionFactory>(connectionString); _sqlBuilder = SqlBuilderFactory.NewSqlBuilder <EntityDummy, BultinSqlBuilderFactory>(connection); }
public Database(string providerName, string dbConnectionString) { DbProviderFactory = GetFactory(providerName); DbConnectionString = dbConnectionString; SqlBuilderFactory = GetSqlBuilderFactory(providerName); }
public async Task <int> Delete <T>(T entity) where T : class, new() { (string sql, List <DatabaseParameter> parameters) = SqlBuilderFactory.GetInstance <T>().BuildDelete(entity); var result = await DalClientFactory.GetClient(GetLogicDatabaseName <T>()).Execute(sql, parameters, null); return(result.ReturnCode); }
public void NewSqlBuilder_EntityDummy_SqlBuilder() { var connectionString = Config.Instance().GetConnectionString(); var connection = ConnectionFactory.NewConnection <SqlServerConnectionFactory>(connectionString); var builder = SqlBuilderFactory.NewSqlBuilder <EntityDummy, BultinSqlBuilderFactory>(connection); Assert.NotNull(builder); }
private void fillTreeView() { if (cmbServers.Items.Count == 0) { return; } //ama den iparxei kanenas server den to kanei sqlservers server = null; this.Invoke((MethodInvoker) delegate() { server = sqlservers.CreateSqlServerFromDataTable(serverData, cmbServers); }); ConnectionResultSet result = DB.TestConnection(server); if (result.wasSuccessful) { DbConnection con = DB.connect(server); List <string> databases = null; if (Utils._convert(server.db_type) == sqlbox.commons.DbType.SQLITE) { databases = new List <string>() { "main" }; } else { databases = new SqlBuilderFactory(server) .Create(null).removeSystemDatabases(DbDataHelper.getDatabases(server, con), !hideSystemDatabases); } foreach (string database in databases) { this.Invoke((MethodInvoker) delegate() { TreeNode node = new TreeNode(database); node.ImageIndex = 0; List <string> tables = DbDataHelper.getTables(server, database, con); foreach (string table in tables) { TreeNode tablenode = new TreeNode(table); tablenode.ImageIndex = 1; node.Nodes.Add(tablenode); } tvDatabases.Nodes.Add(node); }); } DB.close(con); } else { this.Invoke((MethodInvoker) delegate() { MessageBox.Show("Connection failed: \n" + result.errorMessage, "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error); }); } }
public async Task <List <T> > QueryLike <T>(IDatabaseParameterLink link, int?recordCount = null) where T : class, new() { var mapper = EntityMetaDataMapper.GetInstance(); // 获取组装好的sql和参数 (string sql, List <DatabaseParameter> parameters) = SqlBuilderFactory.GetInstance <T>().BuildSelect <T>(link, recordCount); var dataSet = await DalClientFactory.GetClient(GetLogicDatabaseName <T>()).Query(sql, parameters); return(mapper.Convert <T>(dataSet)); }
//returns all fields from all tables internal static List <Table> getTablesInfo(sqlservers server, DbConnection con) { var list = new List <Table>(); try { if (sql.Utils.IsDbEmbedded(server.db_type)) { //case of embedded like sqlite the process to get all fields from all tables is very different. //first get all tables List <string> tables = getTables(con); //and then for every each one get table fields foreach (string table in tables) { string table_info = new SqlBuilderFactory(server).Create(con.Database).describeTableSql(table); using (var r = new DbCommandFactory(con, table_info).Create().ExecuteReader()) { while (r.Read()) { list.Add(new Table(table, r.GetString(1), r.GetString(2), r.GetInt32(3) == 0 ? "YES" : "NO", 0)); } } Terminal.MainTerminal.AppendText(table_info); } } else { string sql = new SqlBuilderFactory(server).Create(con.Database).getAllFieldsFromAllTablesInDb(); using (var r = new DbCommandFactory(con, sql).Create().ExecuteReader()) { while (r.Read()) { list.Add(new Table(r.GetString(0), r.GetString(1), r.GetString(2), r.GetString(3), r.GetValue(4) != DBNull.Value ? r.GetInt64(4) : default)); } } Terminal.MainTerminal.AppendText(sql); } } catch (DbException ex) { Terminal.MainTerminal.AppendText(ex.Message); #if DEBUG Console.WriteLine(ex.Message); #endif } return(list); }
public static void RegisterSqlBuilderFactory(SqlBuilderFactory factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (factory.ProviderName == null) { throw new ArgumentNullException(nameof(factory.ProviderName)); } lock (SqlBuilderFactories) { SqlBuilderFactories.Add(factory.ProviderName, factory); } }
public void SelectWithIfStatementTest(bool ifStatementResult, string schemaPrefixId, string expectedSql) { SqlAliasHelper.ClearAliases(); var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(null, schemaPrefixId, SupportedDatabaseTypes.Postgres); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId() ?? string.Empty); var builder = dbConfig.SqlBuilder(); var sql = builder.Select() .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .WhereIf <Entity>(x => x.WV(item => item.Name, "Arild"), () => ifStatementResult) .Build(); sql.Should().Be(expectedSql); }
public void DeleteTest(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { var useSchema = !string.IsNullOrEmpty(schema); var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId() ?? string.Empty); var builder = dbConfig.SqlBuilder(); var delete = builder.Delete <Entity>(); var sql = delete .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .Where(x => x.WP(item => item.Id, "IdParam")) .Where(x => x.WV(item => item.Name, "Arild")) .Build(); sql.Should().Be(expectedSql); }
public void InsertTest_WithEnumAndDirectProperty(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { var useSchema = !string.IsNullOrEmpty(schema); var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId()); var builder = dbConfig.SqlBuilder(); var resolver = dbConfig.DatabaseParameterResolver(); var insert = builder.Insert <Entity>(); var sql = insert .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .Fields(x => x.FV(f => f.Id, resolver.WithNextSequence("seq"), true)) .Fields(x => x.FV(f => f.Name, "Arild")) .Fields(x => x.FP(f => f.Description)) .Fields(x => x.FP(f => f.EntityEnum)) .Fields(x => x.FP("SomeProperty")) .Build(); sql.Should().Be(expectedSql); }
public void UpdateTest_WithTableNameSet2(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { const string tableName = "EntityTable"; var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); var useSchema = !string.IsNullOrEmpty(schema); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId()); var builder = dbConfig.SqlBuilder(); var update = builder.Update <Entity>(tableName); var sql = update .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .Fields(x => x.FP(f => f.Description) .FV(f => f.Name, "Arild")) .Where(x => x.WP(item => item.Id, "IdParam")) .Build(); sql.Should().Be(expectedSql); }
public void UpdateTestWithWhereIfTest(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); var ifStatementResult = !string.IsNullOrEmpty(schema); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId()); var builder = dbConfig.SqlBuilder(); var update = builder.Update <Entity>(); var sql = update .OnSchema(schema, () => schema != null) .Fields(x => x.FP(f => f.Description) .FV(f => f.Name, "Arild")) .Where(x => x.WP(item => item.Id, "IdParam")) .WhereIf(x => x.WV(item => item.Name, "Arild", OP.DI), () => ifStatementResult) .Build(); sql.Should().Be(expectedSql); }
/// <summary> /// 条件查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="criteria"></param> /// <returns></returns> public async Task <List <T> > Query <T>(T criteria, int?recordCount = null) where T : class, new() { var mapper = EntityMetaDataMapper.GetInstance(); // 获取组装好的sql和参数 (string sql, List <DatabaseParameter> parameters) = SqlBuilderFactory.GetInstance <T>().BuildSelect(criteria, recordCount); var logicName = databaseName; if (string.IsNullOrWhiteSpace(logicName)) { logicName = mapper.Get <T>().DatabaseName; } var client = DalClientFactory.GetClient(logicName); var dataSet = await client.Query(sql, parameters); return(mapper.Convert <T>(dataSet)); }
public void InsertTest(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { var useSchema = !string.IsNullOrEmpty(schema); var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId()); var builder = dbConfig.SqlBuilder(); var insert = builder.Insert <Entity>(); var sql = insert .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .Fields(x => x.FP(f => f.Id, "IdParam")) .Fields(x => x.FV(f => f.Name, "Arild")) .Fields(x => x.FP(f => f.Description)) .Build(); sql.Should().Be(expectedSql); }
static void Main(string[] args) { var constr = ConfigurationManager.ConnectionStrings["YF"].ToString(); IDbConnection connection = new SqlConnection(constr); var obj = new List <decimal>() { 491, 494, 511, 525, 531, 577, 763 }; ISqlBuilderAction builder = SqlBuilderFactory.CheckFactory <OR_Person>(SqlBuilderEnum.Select); //builder.Add("Id in @Id", "Id", obj); builder.Add("Name like @Name", "Name", "%张%"); var list = connection.Query <OR_Person>(builder.Sql, builder.Parameters).ToList(); foreach (var item in list) { Console.WriteLine(item.Name); } //conn.Open(); //var count =conn.ExecuteScalarAsync<int>("SELECT count(1) FROM[dbo].[tag] a"); //conn.Close(); //conn = new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=cms;Pooling=true;Max Pool Size=11"); //conn.Open(); //var items =conn.QueryAsync("SELECT TOP 20 a.[id], a.[parent_id], a.[name] FROM[dbo].[tag] a"); //conn.Close(); //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); //watch.Start(); //开始监视代码运行时间 //watch.Stop(); //停止监视 //TimeSpan timespan = watch.Elapsed; //获取当前实例测量得出的总时间 //timespan.Seconds.ToString(); //Console.WriteLine(timespan.TotalMilliseconds.ToString()); //Select(new OR_Person()); Console.ReadKey(); }
public async Task <int> Insert <T>(T entity) where T : class, new() { // 获取组装好的sql和参数 (string sql, List <DatabaseParameter> parameters) = SqlBuilderFactory.GetInstance <T>().BuildInsert(entity); var client = DalClientFactory.GetClient(GetLogicDatabaseName <T>()); // 将主键返回给实体 var hints = DalHints.Create(); // 如果当前实例含有自增主键,且自增主键的实体不为空,那么需要数据库返回自增住居 var identity = EntityMetaDataMapper.GetInstance().Get <T>().Columns.Find(p => p.Attribute.Identity); if (identity != null && identity.Attribute.Identity && identity.ColumnProperty.GetValue(entity) == null) { hints.Add(DalHint.SetIdentity); } var result = await client.Execute(sql, parameters, hints); // 如果数据库返回了主键,那么将主键设置回实体 // 暂时先这么写 if (result.Identity > 0) { if (identity.ColumnProperty.PropertyType == typeof(int?)) { int.TryParse(result.Identity.ToString(), out var value); identity.ColumnProperty.SetValue(entity, value); } else { long.TryParse(result.Identity.ToString(), out var value); identity.ColumnProperty.SetValue(entity, value); } } return(result.ReturnCode); }
public void SelectCountTestOneTableOnly(SupportedDatabaseTypes databaseTypes, string schema, string schemaPrefixId, string expectedSql) { SqlAliasHelper.ClearAliases(); var dbConfig = SqlBuilderFactory.DbConfigSchemaTargets(schema, schemaPrefixId, databaseTypes); var useSchema = !string.IsNullOrEmpty(schema); expectedSql = string.Format(expectedSql, dbConfig.Schema, dbConfig.GetSchemaPrefixId() ?? string.Empty); var builder = dbConfig.SqlBuilder(); var select = builder.Select(); var sqls = new List <string> { select .Count() .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .Where <Entity>(x => x.WV(item => item.Name, "Arild")) .Build(), select .Count() .OnSchema(setSchemaNameIfExpressionIsEvaluatedToTrue: () => useSchema) .From <Entity>() .Fields <Entity>(x => x.F(item => item.Name)) .Fields <Entity>(x => x.F(item => item.Description)) .Where <Entity>(x => x.WP(item => item.Id, "IdParam")) .Where <Entity>(x => x.WV(item => item.Name, "Arild")) .Build() }; foreach (var sql in sqls) { sql.Should().Be(expectedSql); } }
internal static List <string> getTableFields(DbConnection con, string table) { var data = new List <string>(); string command = ""; try { command = new SqlBuilderFactory(con).Create(con.Database).describeTableSql(table); using (var reader = new DbCommandFactory(con, command).Create().ExecuteReader()) { if (!sql.Utils.IsDbEmbedded(sql.Utils.GetDbTypeEnum(con))) { while (reader.Read()) { data.Add(reader.GetString(0) + " " + reader.GetString(1) + ", Nullable:" + reader.GetString(2)); } } else { while (reader.Read()) { data.Add(reader.GetString(1) + " " + reader.GetString(2) + ", Nullable:" + (reader.GetInt32(3) == 1 ? "NO" : "YES")); } } } } catch (DbException ex) { command = ex.Message; #if DEBUG Console.WriteLine(ex.Message); #endif } Terminal.MainTerminal.AppendText(command); return(data); }