这是我试图做的代码:
public IListGetAll() { using (var c = new MyDataContext()) { return c.Operators.ToList(); } }
运算符实现IOperator,但我收到以下编译错误:
Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Collections.Generic.IList '. An explicit conversion exists (are you missing a cast?)
我该怎么做才能得到我需要的东西?
尝试Cast<>()
方法:
return c.Operators.Cast().ToList();