62,270
社区成员
发帖
与我相关
我的任务
分享public class 待选集合
{
public List<待选成员> 待选成员 { get; set; }
}
public class 待选成员
{
public byte 位置 { get; set; }
public List<添加剂们> 添加剂们 { get; set; }
}
public ActionResult recognise(int id)
{
var 纪录 = 库.历史查询.Find(id);
待选集合 待选集合 = new 待选集合();
foreach (var 配料 in 纪录.用户确认)
{
待选成员 待选成员 = new 待选成员 { 位置 = 配料.位置 };
if (配料.类型 == "添加剂" && String.IsNullOrEmpty(配料.确认后))
{
Expression<Func<添加剂们, bool>> 条件 = w => 配料拆分(w.英文名).Intersect(配料拆分(配料.确认前)).Any();
待选成员.添加剂们 = 库.添加剂们.Where(条件.Compile()).OrderByDescending(o => 配料拆分(o.英文名).Intersect(配料拆分(配料.确认前)).Count()).ToList();
}
待选集合.待选成员.Add(待选成员);
}
ViewBag.添加剂们 = 待选集合;
return View(纪录);
}调试发现 待选成员.添加剂们 的值为空,是不是它的赋值语句写的不对?public class 待选集合
{
public List<待选成员> 待选成员 { get; set; } = new List<待选成员>();
}
public class 待选成员
{
public byte 位置 { get; set; }
public List<添加剂们> 添加剂们 { get; set; } = new List<添加剂们>();
}