How To Do A Select Distinct Equivalent For A Page Filter In Nhibernate?
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
Solution 1:
Solution 2:
ANSWER: I have 29 records in the table with 4 records repeated twice. I want only Distinct results. So, the total number of records should be 25.
below is test method
[TestMethod]
publicvoidUserApplicationsTest()
{
int usercount = 25;
string query = "select from User u left outer join fetch u.ApplicationRequests ar";
ISession session = NHibernateSessionManager.GetSession();
IList<User> users = session.CreateQuery
(
query
)
.List<User>()
.Distinct<User>().ToList();
Assert.AreEqual(usercount, users.Count);
}
Solution 3:
criterion = ... //SELECT Title FROM Employees ORDERBY Title
criterion.SetResultTransformer(new NHibernate.Transform.DistinctRootEntityResultTransformer())
Post a Comment for "How To Do A Select Distinct Equivalent For A Page Filter In Nhibernate?"