Vin*_*sna 1 c# linq entity-framework-core
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();
Run Code Online (Sandbox Code Playgroud)
昨天我花了一个晚上终于能够多重批准数据,并简化一些代码。这一觉睡得非常好。今天早上我继续我的工作,它不再工作了。虽然我通过云转移到另一台电脑,但应该是一样的。我仍在寻找为什么它不起作用以及为什么昨天它像魅力一样起作用。我想确认一下我是否可以这样做?
.Where(e => e.Id.Contains(ids.ToString()));
Run Code Online (Sandbox Code Playgroud)
因为当我删除 .Where 时,它起作用了。所以 .Contains 肯定有问题。我检查了 ids,它正确返回了精确的字符串标识符。
你把逻辑写反Contains了
var spr = this.contextSQL.ProductSubProductRate.Where(e => e.Id.Contains(ids.ToString()));\nRun Code Online (Sandbox Code Playgroud)\n用。。。来代替
\nvar spr = this.contextSQL.ProductSubProductRate.Where(e => ids.Contains(\xd0\xb5.Id));\nRun Code Online (Sandbox Code Playgroud)\n