我有两个要返回视图的列表,“已添加”和“已删除”。但是目前我只能返回“添加”或“删除”。我怎样才能在一个对象中返回两者?我对 MVC 很陌生,如果这段代码很乱,我深表歉意!
public ActionResult Index()
{
// Excel upload history
var fptexcel = db.FPTStaticDataRatedFinancialAssetBase
.OrderBy(e => e.FORATExcelId)
.Select(e => e.FORATExcelId).Max();
var fptexcelprevious = fptexcel - 1;
var newassets = db.FPTStaticDataRatedFinancialAssetBase.OfType<FPTStaticDataRatedFinancialAssetBase>()
.Where(c => c.FORATExcelId == fptexcel || c.FORATExcelId == fptexcelprevious)
.GroupBy(x => x.Name)
.Where(c => c.Count() == 1)
.Select(y => y.FirstOrDefault()).ToList();
var added = db.FPTStaticDataRatedFinancialAssetBase.OfType<FPTStaticDataRatedFinancialAssetBase>()
.Where(x => x.FORATExcelId == fptexcelprevious)
.Select(x => x).ToList();
var removed = db.FPTStaticDataRatedFinancialAssetBase.OfType<FPTStaticDataRatedFinancialAssetBase>()
.Where(x => x.FORATExcelId == fptexcel)
.Select(x => x).ToList();
return View(newassets.Except(added).ToList());
}