我正在尝试做这样的事情...
public static List<string> GetAttachmentKeyList()
{
DataClassesDataContext dc = new DataClassesDataContext();
List<string> list = from a in dc.Attachments
select a.Att_Key.ToString().ToList();
return list;
}
Visual Studio提示:
无法隐式将类型'System.Linq.IQueryable'转换为'System.Collections.Generic.List'。 存在显式转换(是否缺少强制转换?)
正确的语法是什么?
.ToList()
是在ToString()
返回的字符串上调用的,因此linq表达式求值为类似于IEnumerable<List<char>>
而不是List<string>
。 - Binary Worrier