gpt4 book ai didi

c# - NHibernate 返回 Dictionary

转载 作者:行者123 更新时间:2023-11-30 20:10:42 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com