var ids = new List<string>();
foreach (int rowHandle in this.viewRateManager.GetSelectedRows())
{
ids.Add(this.viewRateManager.GetRowCellValue(rowHandle, "Id").ToString());
}
var spr = this.contextSQL.ProductSubProductRate.Where(e => e.Id.Contains(ids.ToString()));
DateTime time = this.contextSQL.Database.SqlQuery<DateTime>($"SELECT NOW()").AsEnumerable().FirstOrDefault();
foreach (var item in spr)
{
if (item.Approver != null) { continue; }
item.Approver = Core.cxCore.ActiveAccount;
item.Approved = time;
}
this.contextSQL.SaveChanges();
昨天花了一个晚上终于能够多重审批数据,并且简化了一些代码。这一觉睡得非常好。 今天早上我继续我的工作,它不再工作了。尽管我通过云从 Surface 到笔记本进行编码。我仍在寻找为什么它不起作用以及为什么昨天它像魅力一样起作用。我想确认一下我是否可以这样做?
.Where(e => e.Id.Contains(ids.ToString()));
因为当我删除.Where时,它起作用了。所以 .Contains 肯定有问题。 我检查了 ids,它正确返回了精确的字符串标识符。
你把逻辑写反了
Contains
var spr = this.contextSQL.ProductSubProductRate.Where(e => e.Id.Contains(ids.ToString()));
替换为
var spr = this.contextSQL.ProductSubProductRate.Where(e => ids.Contains(x.Id));