最近工作中,遇到了一个问题,最后发现是在使用string.Format的时候,由于查询条件太多,导致赋值的时候出错。

string sqlOne = string.Format(@" select * from MD_Person  where Code='{0}' AND Role=N'{1}' AND Type=N'{2}'", code, role, type);

这种写法,当查询条件特别多的时候,容易出错。

最后将string.Format都是用$来替换

string sqTwo = $"select * from MD_Person where Code='{code}' AND Role='{role}' AND Type='{type}'";

 

相关文章:

  • 2021-11-10
  • 2022-03-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-04
  • 2021-06-24
  • 2021-12-02
  • 2021-09-19
  • 2021-12-14
  • 2021-07-08
相关资源
相似解决方案