如何做一个SELECT DISTINCT等同于NHibernate的网页过滤器? [英] How to do a SELECT DISTINCT equivalent for a page filter in NHibernate?

查看:219
本文介绍了如何做一个SELECT DISTINCT等同于NHibernate的网页过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你正在使用的SQL 2005 Northwind数据库的安装副本。 你的工作与员工浏览网页的ASP.NET应用程序。 在页面的顶部,你有一个标题过滤器,你想在一个下拉列表显示这5个选项:

Lets say you are working in SQL 2005 with a copy of Northwind database installed. Your working on an ASP.NET application with an Employees "browse" page. At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown:

[全部]
  副president,销售
  销售再presentative
  销售经理
  内部销售协调员

[ALL]
Vice President, Sales
Sales Representative
Sales Manager
Inside Sales Coordinator

在T-SQL中,你会使用类似下面的语句,让您的列表。

In T-SQL you would use something like the statement below to get your list.

SELECT DISTINCT Title FROM Employees ORDER BY Title

什么是NHibernate的这样做的最好方法是什么?假设初始数据库设计是有点无法控制(就像罗斯文)的......这意味着你将不会被创建一个标题或职位表正常化。

What is the best way of doing this in NHibernate? Assume that the initial database design is somewhat out of your control (just like Northwind)... Meaning that you won't be creating a Titles or Positions table for normalization.

感谢。

推荐答案

见的 nhibernate.info/doc/howto/various/get-unique-results-from-joined-queries.html

这篇关于如何做一个SELECT DISTINCT等同于NHibernate的网页过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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