A common C# class to manipulate ralational database system using ADO.NET.
- compile the class library and add reference of the dlls including the "DatabaseInvoke.dll" and other dependencies (ADO Drivers of the databases) to your project.
- add using statement to your namespaces.
- you can call the functions by using the following code.
- connection resources will be cleaned automatically after the using code block
using (SqlManipulation sm = new SqlManipulation(Properties.Settings.Default.ConnectionString, (SqlType)(Enum.Parse(typeof(SqlType), Properties.Settings.Default.SqlType, true))))
{
sm.Init();
//call functions inside
sm.ExcuteNonQuery(sql);
sm.OracleBlobNonQuery(sqlBlob, Path);
}
- Dapper is very convenient ORM library. The DatabaseInvoke project works perfectly with Dapper. You MUST add reference to Dapper manually in your project to make use of it.
//POCO Class
public class Point3D
{
public int X;
public int Y;
public int Z;
}
using Dapper;
//namespace and class declaration here.
public IEnumerable<Point3D> GetList()
{
IEnumerable<Point3D> list = new List<Point3D>();
string sql = "SELECT X = @X,Y = @Y, Z = @Z from table";
using (SqlManipulation sm = new SqlManipulation(ConnectionString, SqlType.PostgresQL))
{
sm.Init();
list = sm.Connection.Query<Point3D>(sql);
}
return list;
}
alternatively, you can directly start a project from the solution. By adding a new project into the solution, you can easily make use of the class.
- Use the correct library (.NET4.0 or .NET Standard 2.0)
- Oracle users might encounter denpendency errors when targeting .NET Framework if they are using .NET Standard version of the library. Replacing Oracle.ManagedDataAccess.Core with Oracle.ManagedDataAccess via nuget will solve the problem.
- If you can not compile the project when you include the project source to your existing project. Nuget commandline update-package --reinstall will help you.
- Port to .Net Standard
- Publish a nuget version