NHibernate返回Dictionary< int,string> [英] NHibernate to return Dictionary <int, string>

查看:116
本文介绍了NHibernate返回Dictionary< int,string>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从nhibernate查询返回Dictionary < int,string>

Is it possible to return Dictionary<int, string> from an nhibernate query such as this:

CreateQuery("select CustomerId, FullName from Customer")  

我从这个论坛尝试了一些例子,使用.net ToDictionary方法,但是无法让它们工作。

I've tried a few examples from this forum using the .net ToDictionary method, but am unable to get them to work.

推荐答案

您需要在列表或枚举上执行以下操作,您应该得到dictonary

You need to do the following on your list or enumerable and you should get the dictonary

.ToDictionary(x => x.CustomerId, x => x.FullName);

这篇关于NHibernate返回Dictionary&lt; int,string&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆