【freesql】使用Ado执行sql语句查询结果集时参数化举例


 

StringBuilder sb = new StringBuilder();
sb.Append("select a.id,a.stationid,a.stationname,a.stationdesc,a.keycode,");
sb.Append("b.address,b.area,b.city,b.establishtime,b.installedcapacity,b.installedpower,b.latitude,b.longitude,");
sb.Append("left join enery_storage_station c on a.stationid = c.stationid ");
sb.Append(" where 1=1 ");
if (!string.IsNullOrWhiteSpace(name))
{
sb.AppendFormat(" and a.stationname like '%{0}%'",@name);
}
return _repository.GetIFreeSql().Ado.Query<StationsInfoModel>(sb.ToString(), new SqlParameter { ParameterName = "@name", Value = name });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM