CPSysUDB 1.0.3

Biblioteca .NET para facilitar comunicação com SQL Server e MySQL, pare de usar query e crie um sistema com banco de dados híbrido

There is a newer version of this package available.
See the version list below for details.
Install-Package CPSysUDB -Version 1.0.3
dotnet add package CPSysUDB --version 1.0.3
<PackageReference Include="CPSysUDB" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CPSysUDB --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CPSysUDB, 1.0.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CPSysUDB as a Cake Addin
#addin nuget:?package=CPSysUDB&version=1.0.3

// Install CPSysUDB as a Cake Tool
#tool nuget:?package=CPSysUDB&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Conexao c = new Conexao(new Conexao.ConexaoData(@"RAFAEL-PC\SQLEXPRESS", Conexao.ConexaoData.Banco.SQLSRV, true, "DB_CHEF", "sa", "***"));
//Conexao c = new Conexao(new Conexao.ConexaoData(@"localhost", Conexao.ConexaoData.Banco.MYSQL, true, "db_teste1", "root", ""));
c.UseLogQuery = true;
Console.WriteLine("TESTE: " + c.TestConexao());
Console.WriteLine("CREATE DATABASE: " + c.NewDataBase("db_teste"));
Console.WriteLine("VERIFICA TABLE EXISTENTE: " + c.VerifyTable("tabela"));
Console.WriteLine("VERIFICA COLUMN EXISTENTE: " + c.VerifyColumn("tabela", "nome"));
List<Conexao.Campos> campos = new List<Conexao.Campos>();
campos.Add(new Conexao.Campos("id", "codigo", "t1", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos.Add(new Conexao.Campos("texto", "texto", "t1", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
Conexao.Table table = new Conexao.Table("tabela", "t1", campos);
Console.WriteLine("ADD TABLE: " + c.NewTable(table, false, true));
List<Conexao.Campos> campos2 = new List<Conexao.Campos>();
campos2.Add(new Conexao.Campos("id", "codigo2", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos2.Add(new Conexao.Campos("texto", "texto2", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
campos2.Add(new Conexao.Campos("idtable", "codigotable", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.INT), false, false, false, true, c.getTableByName("tabela"), c.getCampoByName(c.getTableByName("tabela"), "id")));
campos2.Add(new Conexao.Campos("cadastro", "cadastro", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.DATETIME)));
Conexao.Table table2 = new Conexao.Table("tabela2", "t2", campos2);
Console.WriteLine("ADD TABLE FOREIGN KEY: " + c.NewTable(table2, true, true));
List<Conexao.Campos> campos3 = new List<Conexao.Campos>();
campos3.Add(new Conexao.Campos("id", "codigo", "t3", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos3.Add(new Conexao.Campos("texto", "texto", "t3", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
//campos3.Add(new Conexao.Campos("textoteste", "teste", "t3", new Conexao.TypeCampos(Conexao.Types.NVARCHAR, "100")));
Conexao.Table table3 = new Conexao.Table("tabela3", "t3", campos3);
Console.WriteLine("ADD TABLE VERIFY: " + c.NewTable(table3, true, true));
List<Conexao.Campos> campos4 = new List<Conexao.Campos>();
campos4.Add(new Conexao.Campos("id", "codigo2", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos4.Add(new Conexao.Campos("texto", "texto2", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.VARCHAR, "100")));//campos4.Add(new Conexao.Campos("texto", "texto2", new Conexao.TypeCampos(Conexao.Types.NVARCHAR, "200")));
campos4.Add(new Conexao.Campos("idtable3", "codigotable", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.INT), false, false, false, true, c.getTableByName("tabela3"), c.getCampoByName(c.getTableByName("tabela3"), "id")));
Conexao.Table table4 = new Conexao.Table("tabela4", "t4", campos4);
Console.WriteLine("ADD TABLE FOREIGN KEY: " + c.NewTable(table4, true, true));
List<object> valores = new List<object>();
valores.Add("teste");
Console.WriteLine("INSERT: " + c.Insert(c.getTableByName("tabela"), valores));
List<object> valores3 = new List<object>();
valores3.Add("teste");
valores3.Add(1);
valores3.Add(DateTime.Now);
Console.WriteLine("INSERT 2: " + c.Insert(c.getTableByName("tabela2"), valores3));
List<object> valores2 = new List<object>();
valores2.Add("teste 123");
List<Conexao.Where> where = new List<Conexao.Where>();
where.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 3));
Console.WriteLine("UPDATE: " + c.Update(c.getTableByName("tabela"), c.getTableByName("tabela").Campos, valores2, where));
List<Conexao.Where> where2 = new List<Conexao.Where>();
where2.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 4));
Console.WriteLine("DELETE: " + c.Delete(c.getTableByName("tabela"), where2));
List<Conexao.Select> select = new List<Conexao.Select>();
List<Conexao.Where> where3 = new List<Conexao.Where>();
List<Conexao.Join> join = new List<Conexao.Join>();
List<Conexao.Campos> campss = new List<Conexao.Campos>();
foreach (Conexao.Campos item in c.getTableByName("tabela").Campos)
{
campss.Add(item);
}
foreach (Conexao.Campos item in c.getTableByName("tabela2").Campos)
{
campss.Add(item);
}
join.Add(new Conexao.Join(c.getTableByName("tabela2"), c.getCampoByName(c.getTableByName("tabela"), "id"), c.getCampoByName(c.getTableByName("tabela2"), "idtable")));
where3.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 1));
Conexao.Select sel = new Conexao.Select(c.getTableByName("tabela"), campss, false, join, where3, null, null, Conexao.Select.Union.NONE, null, null, 1);
select.Add(sel);
Console.WriteLine("SELECT: ");
DataSet ds = c.SelectValue(select);
if (ds != null)
{
Console.WriteLine(" COUNT: " + ds.Tables[0].Rows.Count);
string column = "", rows = "";
foreach (DataColumn dataColumn in ds.Tables[0].Columns)
{
column = column + " # " + dataColumn.Caption;
}
Console.WriteLine(" " + column);
foreach (DataRow dataRow in ds.Tables[0].Rows)
{
rows = "";
foreach (var item in dataRow.ItemArray)
{
rows = rows + " # " + item;
}
Console.WriteLine(" " + rows);
}
}

Conexao c = new Conexao(new Conexao.ConexaoData(@"RAFAEL-PC\SQLEXPRESS", Conexao.ConexaoData.Banco.SQLSRV, true, "DB_CHEF", "sa", "***"));
//Conexao c = new Conexao(new Conexao.ConexaoData(@"localhost", Conexao.ConexaoData.Banco.MYSQL, true, "db_teste1", "root", ""));
c.UseLogQuery = true;
Console.WriteLine("TESTE: " + c.TestConexao());
Console.WriteLine("CREATE DATABASE: " + c.NewDataBase("db_teste"));
Console.WriteLine("VERIFICA TABLE EXISTENTE: " + c.VerifyTable("tabela"));
Console.WriteLine("VERIFICA COLUMN EXISTENTE: " + c.VerifyColumn("tabela", "nome"));
List<Conexao.Campos> campos = new List<Conexao.Campos>();
campos.Add(new Conexao.Campos("id", "codigo", "t1", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos.Add(new Conexao.Campos("texto", "texto", "t1", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
Conexao.Table table = new Conexao.Table("tabela", "t1", campos);
Console.WriteLine("ADD TABLE: " + c.NewTable(table, false, true));
List<Conexao.Campos> campos2 = new List<Conexao.Campos>();
campos2.Add(new Conexao.Campos("id", "codigo2", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos2.Add(new Conexao.Campos("texto", "texto2", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
campos2.Add(new Conexao.Campos("idtable", "codigotable", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.INT), false, false, false, true, c.getTableByName("tabela"), c.getCampoByName(c.getTableByName("tabela"), "id")));
campos2.Add(new Conexao.Campos("cadastro", "cadastro", "t2", new Conexao.TypeCampos(Conexao.Campos.Types.DATETIME)));
Conexao.Table table2 = new Conexao.Table("tabela2", "t2", campos2);
Console.WriteLine("ADD TABLE FOREIGN KEY: " + c.NewTable(table2, true, true));
List<Conexao.Campos> campos3 = new List<Conexao.Campos>();
campos3.Add(new Conexao.Campos("id", "codigo", "t3", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos3.Add(new Conexao.Campos("texto", "texto", "t3", new Conexao.TypeCampos(Conexao.Campos.Types.NVARCHAR, "100")));
//campos3.Add(new Conexao.Campos("textoteste", "teste", "t3", new Conexao.TypeCampos(Conexao.Types.NVARCHAR, "100")));
Conexao.Table table3 = new Conexao.Table("tabela3", "t3", campos3);
Console.WriteLine("ADD TABLE VERIFY: " + c.NewTable(table3, true, true));
List<Conexao.Campos> campos4 = new List<Conexao.Campos>();
campos4.Add(new Conexao.Campos("id", "codigo2", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.INT), true, true));
campos4.Add(new Conexao.Campos("texto", "texto2", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.VARCHAR, "100")));//campos4.Add(new Conexao.Campos("texto", "texto2", new Conexao.TypeCampos(Conexao.Types.NVARCHAR, "200")));
campos4.Add(new Conexao.Campos("idtable3", "codigotable", "t4", new Conexao.TypeCampos(Conexao.Campos.Types.INT), false, false, false, true, c.getTableByName("tabela3"), c.getCampoByName(c.getTableByName("tabela3"), "id")));
Conexao.Table table4 = new Conexao.Table("tabela4", "t4", campos4);
Console.WriteLine("ADD TABLE FOREIGN KEY: " + c.NewTable(table4, true, true));
List<object> valores = new List<object>();
valores.Add("teste");
Console.WriteLine("INSERT: " + c.Insert(c.getTableByName("tabela"), valores));
List<object> valores3 = new List<object>();
valores3.Add("teste");
valores3.Add(1);
valores3.Add(DateTime.Now);
Console.WriteLine("INSERT 2: " + c.Insert(c.getTableByName("tabela2"), valores3));
List<object> valores2 = new List<object>();
valores2.Add("teste 123");
List<Conexao.Where> where = new List<Conexao.Where>();
where.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 3));
Console.WriteLine("UPDATE: " + c.Update(c.getTableByName("tabela"), c.getTableByName("tabela").Campos, valores2, where));
List<Conexao.Where> where2 = new List<Conexao.Where>();
where2.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 4));
Console.WriteLine("DELETE: " + c.Delete(c.getTableByName("tabela"), where2));
List<Conexao.Select> select = new List<Conexao.Select>();
List<Conexao.Where> where3 = new List<Conexao.Where>();
List<Conexao.Join> join = new List<Conexao.Join>();
List<Conexao.Campos> campss = new List<Conexao.Campos>();
foreach (Conexao.Campos item in c.getTableByName("tabela").Campos)
{
campss.Add(item);
}
foreach (Conexao.Campos item in c.getTableByName("tabela2").Campos)
{
campss.Add(item);
}
join.Add(new Conexao.Join(c.getTableByName("tabela2"), c.getCampoByName(c.getTableByName("tabela"), "id"), c.getCampoByName(c.getTableByName("tabela2"), "idtable")));
where3.Add(new Conexao.Where(c.getCampoByName(c.getTableByName("tabela"), "id"), Conexao.Where.Command.EQUALS, 1));
Conexao.Select sel = new Conexao.Select(c.getTableByName("tabela"), campss, false, join, where3, null, null, Conexao.Select.Union.NONE, null, null, 1);
select.Add(sel);
Console.WriteLine("SELECT: ");
DataSet ds = c.SelectValue(select);
if (ds != null)
{
Console.WriteLine(" COUNT: " + ds.Tables[0].Rows.Count);
string column = "", rows = "";
foreach (DataColumn dataColumn in ds.Tables[0].Columns)
{
column = column + " # " + dataColumn.Caption;
}
Console.WriteLine(" " + column);
foreach (DataRow dataRow in ds.Tables[0].Rows)
{
rows = "";
foreach (var item in dataRow.ItemArray)
{
rows = rows + " # " + item;
}
Console.WriteLine(" " + rows);
}
}

Release Notes

Adicionando para especificar os campos no método where.

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3.10 207 4/21/2020
1.0.3.9 203 4/18/2020
1.0.3.8 213 4/8/2020
1.0.3 320 4/7/2020
1.0.0 323 3/22/2020