c# - NHibernate 返回 Dictionary <int, string>

标签 c# nhibernate dictionary

是否可以返回字典 <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/

相关文章:

nhibernate - Fluent Nhibernate Composite Key 不为引用实体生成连接

.net - 在长时间运行的操作中管理 NHibernate session

c++ - std::map:使用键类以外的参数重载 operator<

c# - 当我不关心字典的类型时,如何将字典作为参数传递?

c# - 保存从 EAV 数据库结构加载序列化对象

javascript - 在包含 html 代码 jquery 的变量中更改 Id & Class

c# - 两种类型通用接口(interface)的依赖注入(inject)

c# - gRPC:我应该为整个应用程序使用一个客户端吗?

nhibernate - 为 NHibnernate 结合 Fluent 和 XML 映射

Python如何通过应用添加到现有值来用另一个字典更新字典