0

LINQ to Entities does not recognize the method 'System.String[] Split(Char[])' method, and this method cannot be translated into a store expression.

Im trying to convert the string to int as an array.

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();
René Vogt
  • 41,709
  • 14
  • 73
  • 93
YongaJ
  • 180
  • 10

1 Answers1

0

foreach(var item in db.EmpGrpViews) { List 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

            });
        }
YongaJ
  • 180
  • 10