This is a project to introduce simpler type conversion when communicating with a database.
The library here is designed to only communicate through STPs, since it is considered more secure than free SQL.
An example of how this works can be seen below:
var client = new DBClient("<--Database Connection String Here-->");
var dataset = await client.ExecuteAsync("some-stp");
var table = dataset[0];
var row = table[0];
int someValue = row.GetValue<int>("COL_NAME");
You can also deserialize directly into class objects like this:
public class SomeClass
{
[DatabaseSharp(ColumnName = "PK_NAME")]
public string Name { get; set; }
[DatabaseSharp(ColumnName = "ACT_VALUE")]
public int Value { get; set; }
}
var client = new DBClient("<--Database Connection String Here-->");
var dataset = await client.ExecuteAsync("some-stp");
var table = dataset[0];
var row = table[0];
SomeClass filled = row.Fill<SomeClass>();
These are just the methods on the row level. However you can also use these on the Table level, where it will instead make a list of the items, as such:
var client = new DBClient("<--Database Connection String Here-->");
var dataset = await client.ExecuteAsync("some-stp");
var table = dataset[0];
List<int> someValue = table.GetAllValues<int>("COL_NAME");
The project is available as a package on the NuGet Package Manager.