DataAccess
Author: Victor.X.Qu
Email: [email protected]
DataAccess is a c# project for sql data mapping to object, like dapper
DataAccess is for net core , so it base on netstandard1.3
db supports
DataAccess base on ado.net, so you can use blow db :
- MSSql
- MySql
- PostgreSQL
- SQLite
use MSSql example
Use config file
dependencies
"dependencies": {
"VIC.DataAccess.MSSql": "1.0.1",
"VIC.DataAccess.Config": "1.0.1"
},
You can config sql in xml file for DataAcces, like:
Code for use :
var provider = new ServiceCollection()
.UseDataAccess()
.UseDataAccessConfig(Directory.GetCurrentDirectory(), false, "db.xml")
.BuildServiceProvider();
List students = GenerateStudents(count);
var db = provider.GetService();
var command = db.GetCommand("BulkCopy");
await command.ExecuteBulkCopyAsync(students);
var command = db.GetCommand("SelectByName");
Student s = await command.ExecuteEntityAsync(new { Name = "3" });
var command = db.GetCommand("SelectAll");
List students = await command.ExecuteEntityListAsync();
var command = db.GetCommand("SelectAllAge");
int? age = await command.ExecuteScalarAsync();
No config file
dependencies
"dependencies": {
"VIC.DataAccess.MSSql": "1.0.1"
},
var provider = new ServiceCollection()
.UseDataAccess()
.BuildServiceProvider();
var command = provider.GetService();
command.ConnectionString = "sqlConnectionString";
command.Text = "sql";
command.Type = CommandType.Text;
Student s = await command.ExecuteEntityAsync(new { Name = "3" });
Test performance
You can see the simple code in https://github.com/fs7744/DataAccess/blob/master/example/MSSqlExample
All package
- VIC.ObjectConfig
- VIC.DataAccess
- VIC.DataAccess.Config
- VIC.DataAccess.MSSql
- VIC.DataAccess.MySql
- VIC.DataAccess.PostgreSQL
- VIC.DataAccess.SQLite