对象映射生成sql语句,将sql的拼接转换为对象拼接输出sql语句,减少拼接sql的麻烦和容易出错,例子:
stringselect=Provider.Singleton.Select<Info>() .From<Info>() .Where(newInfo(){name="bouyei",age=12}) .SqlString;select结果:"Selectname,ageFromInfoWherename='bouyei'Andage=12" stringinsert=Provider.Singleton.InsertInto<Info>("tablename", newInfo(){name="newbie",age=13}) .SqlString;insert结果:"InsertIntoInfo(name,age)Values('newbie',13)" stringupdate=Provider.Singleton.Update<Info>() .Set<Info>(newInfo(){name="openthinking.cn",age=11}) .Where<Info>(newInfo(){name="bouyei",age=2}) .SqlString;update结果:"UpdateInfoSetname='openthinking.cn',age=11Wherename='bouyei'Andage=2" stringdelete=Provider.Singleton.Delete<Info>() .From<Info>() .Where<Info>(x=>x.name=="bouyei") .SqlString;
delete结果:"DeleteFromInfoWhere(name='bouyei')"
评论