对象映射生成sql语句,将sql的拼接转换为对象拼接输出sql语句,减少拼接sql的麻烦和容易出错,例子:
string select = Provider.Singleton.Select() .From() .Where(new Info() { name=”bouyei”,age=12 }) .SqlString;
select结果:”Select name,age From Info Where name=’bouyei’ And age=12 ”
string insert = Provider.Singleton.InsertInto(“tablename”, new Info() { name = “newbie”, age = 13 }) .SqlString;
insert结果:”Insert Into Info (name,age) Values(‘newbie’,13)”
string update = Provider.Singleton.Update() .Set(new Info() { name = “openthinking.cn”, age = 11 }) .Where(new Info() {name=”bouyei”,age=2 }) .SqlString;
update结果:”Update Info Set name=’openthinking.cn’,age=11 Where name=’bouyei’ And age=2 ”
string delete = Provider.Singleton.Delete() .From() .Where(x => x.name == “bouyei”) .SqlString;
delete 结果:”Delete From Info Where (name=’bouyei’) “