LINQ to Entities无法识别方法'System.String [] Split(Char [])',并且该方法无法转换为商店表达式。
我正在尝试将字符串转换为数组的int。
public class EmpFields2WithGroup
{
public int EmpID { get; set; }
public string Name { get; set; }
public string Cell { get; set; }
public List<int> grpID { get; set; }
}
List<EmpFields2WithGroup> Emp = new List<EmpFields2WithGroup>();
Emp = db.EmpGrpViews.Select(x => new EmpFields2WithGroup { EmpID = x.ID, Name = x.Name, Cell = x.Cell, grpID = x.GroupIds.Split(',').Select(int.Parse).ToList()}).ToList();
答案 0 :(得分:0)
foreach(db.EmpGrpViews中的可变项) { 清单grp = item.GroupIds!= null吗? item.GroupIds.Split(',')。Select(y => Int32.Parse(y))。ToList():new List();
Emp.Add(new EmpFields2WithGroup
{
EmpID = item.ID,
Name = item.Name,
Cell = item.Cell,
grpID = grp
});
}