Summary

DynamicSQL は、ORMでよく見る2way SQLのParser部分だけを切り出した軽量のライブラリです。
DynamicSQL is a lightweight library of 2way SQL Parser.

How to use

vb.net
'set sql string
Dim sql As String = "select * from employee where age = /*ds age*/30"

'create parameter dictionary
Dim dic As New Dictionary(Of String, Object)
dic.Add("age", 30)

'create connection
Dim cn As IDbConnection = New SqlClient.SqlConnection("Data Source=localhost\SQLEXPRESS;")

'parse 2way-sql and create command
Dim cmd As IDbCommand = DSQLParser.CreateDbCommand(cn, sql, "@", dic)

'?cmd.CommandText
'select * from employee where age = @age

'?cmd.Parameters
'Name=age, Value=30

c#
//set sql string
string sql = "select * from employee where age = /*ds age*/30";

//create parameter dictionary
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("age", 30);

//create connection
IDbConnection cn = new System.Data.SqlClient.SqlConnection("Data Source=localhost\SQLEXPRESS;");

//parse 2way-sql and create command
IDbCommand cmd = DSQLParser.CreateDbCommand(cn, sql, "@", dic);

//?cmd.CommandText
//select * from employee where age = @age

//?cmd.Parameters
//Name=age, Value=30

detail

Last edited Sep 9, 2014 at 2:02 PM by mk3008, version 6