【发布时间】:2012-12-23 02:33:42
【问题描述】:
此 LINQ 表达式不起作用:
dt.AsEnumerable().ToDictionary<Int64, List<string>> (
dtRow => dtRow.Field<Int64>("CodeVal_1"),
new List<string> {
dtRow => dtRow.Field<string>("CodeVal_2"),
dtRow => dtRow.Field<string>("CountryCode")
}
);
dt 是DataTable,我添加了对DataSetExtensions 的引用。
完整代码
using (DataSet dsIps = DbConnection.db_Select_Query("use mydb select * from tblCountryCodes"))
{
using (DataTable dt = dsIps.Tables[0])
{
dt.AsEnumerable().ToDictionary<Int64, List<string>>(
dtRow => dtRow.Field<Int64>("CodeVal_1"),
new List<string> {
dtRow => dtRow.Field<string>("CodeVal_2"),
dtRow => dtRow.Field<string>("CountryCode")
}
);
}
}
错误列表
【问题讨论】:
-
我怎么能在这样的情况下发布错误:img689.imageshack.us/img689/681/errordb.png 显然是一些结构错误,linq 专家会立即看到它
-
@MonsterMMORPG:您可以发布该错误。也有助于将鼠标悬停在红色波浪上并查看文本,或从 Visual Studio 的错误面板中获取编译器错误。