是否可以返回字典 <int, string>
来自这样的 nhibernate 查询:
CreateQuery("select CustomerId, FullName from Customer")
我已经使用 .net ToDictionary 方法尝试了该论坛中的几个示例,但无法使它们正常工作。
最佳答案
您需要在您的列表或 ienumerable 上执行以下操作,您应该获得字典
.ToDictionary(x => x.CustomerId, x => x.FullName);
关于c# - NHibernate 返回 Dictionary <int, string>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4660015/