C# 有没有办法按以下格式拆分列表:';string1'';string2'';string3';,
我需要对我现有的XtraReport执行一个过滤器,我只想看到一些我有ID的特定记录 当我执行以下代码时,它被成功应用C# 有没有办法按以下格式拆分列表:';string1'';string2'';string3';,,c#,sql,split,filtering,where-in,C#,Sql,Split,Filtering,Where In,我需要对我现有的XtraReport执行一个过滤器,我只想看到一些我有ID的特定记录 当我执行以下代码时,它被成功应用 XtraReportOrder report = new XtraReportOrder(); report.FilterString = "orderId IN ('11092', '11093')"; report.ShowPreviewDialog(); 我想用这样的东西 report.FilterString = "orderId IN
XtraReportOrder report = new XtraReportOrder();
report.FilterString = "orderId IN ('11092', '11093')";
report.ShowPreviewDialog();
我想用这样的东西
report.FilterString = "orderId IN ("+MyList.ToConvertSthConvinient+")";
您可以结合使用
String.Join
、LINQ和字符串插值功能:
report.FilterString = $"orderId IN ({String.Join(", ", MyList.Select(id => $"'{id}'"))})";
我会考虑使用