if (StockLocationRecordsToBeDeleted != null)
{
foreach (int _serverId in StockLocationRecordsToBeDeleted)
{
StockLocation_Record RecordToRemove = db.StockLocation_Record.Where(x => x.ServerLocationId == _serverId).FirstOrDefault();
if (RecordToRemove != null)
{
db.StockLocation_Record.DeleteObject(RecordToRemove);
db.SaveChanges();
}
}
}
这已成功删除了一条记录,但是我必须先创建一个新的StockLocation_Record
,而不能DeleteObject(RecordToRemove).Where(ServerId == _serverId)