QueryOver is a strongly-typed fluent-like wrapper on top of NHibernate ICritieria, a database-agnostic query API that supports query composition.
Questions tagged [queryover]
740 questions
11
votes
1 answer
Complex nHibernate QueryOver expression
I have the following objects in a hierarchy A > B > C > D. Each object is mapped to a table. I'm trying to write the following SQL using QueryOver:
SELECT B
FROM A, B, C, D
WHERE A.ID = B.ID
AND B.ID = C.ID
AND C.ID = D.ID
WHERE A.NUMBER =…

Kyle Novak
- 425
- 6
- 15
11
votes
1 answer
nhibernate queryover join alias with a where-or clause
I'll just post the code:
public IList GetByNameDishTypes(IEnumerable names,
IEnumerable dishTypes)
{
// return dishes (ie food) whose name is in the names enumerable,
// or whose type is in the dish types…

h.alex
- 902
- 1
- 8
- 31
10
votes
6 answers
Mocking out nHibernate QueryOver with Moq
The following line fails with a null reference, when testing:
var awards = _session.QueryOver().Where(x => x.BusinessId == (int)business).List();
My test is like so:
var mockQueryOver = new Mock

PeterG
- 334
- 5
- 20
10
votes
5 answers
Nhibernate + QueryOver: filter with Where ignoring sensitive
I am trying to build a simple query in nHibernate with QueryOver but I want it to convert everything lower-case or ignore sensitive:
Domain.User User = Session.QueryOver()
.Where(x=>x.Login=="username")
…

LeftyX
- 35,328
- 21
- 132
- 193
10
votes
1 answer
QueryOver statement for selecting N rows with descending DateTime order
I am trying to write QueryOver statement for selecting N rows in the descending time order.
session.QueryOver().Take(10).OrderBy(x=>x.DateInserted);
Unfortunately this is not at all working.
Is there any way to sort it out?

navule
- 3,212
- 2
- 36
- 54
9
votes
2 answers
Nhibernate QueryOver. OrderBy using strings property names.
I'm refactoring old-style query CreateCriteria() to QueryOver(). My Wcf service gets string PropertyName to order queries results. For IQueryable I use Dynamic LINQ to do such ordering, for CreateCriteria() - AddOrder().
IList

Ievgen Martynov
- 7,870
- 8
- 36
- 52
8
votes
1 answer
Fluent nHibernate QueryOver SQL 'CASE' equivalent
Basically what I want to do is to write this piece of SQL:
SELECT
CASE
WHEN t.type = 'a' THEN
t.name
ELSE
t.otherName
END
as "Name"
FROM myTable t
in QueryOver

Perpetuum
- 230
- 2
- 10
8
votes
1 answer
How do you work with detached QueryOver instances?
This NHibernate blog entry notes how detached QueryOver queries (analogous to DetachedCriteria) can be created (using QueryOver.Of()). However, looking this over, it doesn't look analogous to me at all.
With DetachedCriteria, I would create my…

Remi Despres-Smyth
- 4,173
- 3
- 36
- 46
8
votes
2 answers
How to incorporate property value conversion into NHibernate QueryOver .SelectList?
I'm looking to incorporate property value translations into my QueryOver queries.
I like writing queries following the Query Object Pattern, directly producing MVC view models. In my view models, I try to use property types that are as simple as…

Sandor Drieënhuizen
- 6,310
- 5
- 37
- 80
8
votes
2 answers
Truncate DateTime in NHibernate QueryOver SelectGroup
I have a fairly run-of-the-mill QueryOver query containing the following,
.SelectList(list => list
.SelectGroup(() => txn.GroupField)
.SelectGroup(() => txn.Date))
.List

John
- 605
- 2
- 7
- 17
8
votes
1 answer
Where ... In ... Or Where ... In ... with NHibernate IQueryOver
I'm trying to emulate subject query with NHibernate's IQueryOver. So far I have
var q = CurrentSession.QueryOver().
WhereRestrictionOn(o => o.Buyer.ID).IsIn(partyIDs).
WhereRestrictionOn(o =>…

Anton Gogolev
- 113,561
- 39
- 200
- 288
8
votes
2 answers
NHibernate QueryOver order by first non-null value (coalescing)
What I'm trying to come up is something that's expressed like this:
var result = Session.QueryOver().OrderBy(f => f.UpdatedAt ?? f.CreatedAt);
Sure enough, this doesn't work. Rough equivalent of this in T-SQL is
... order by…

Anton Gogolev
- 113,561
- 39
- 200
- 288
8
votes
7 answers
NHIbernate: Shortcut for projecting all properties?
I'm trying to generate SQL along the lines of:
SELECT
t.*,
SELECT (...)
FROM Title t
[trimmed]
using QueryOver
Title title = null;
var q = session
.QueryOver(() => title)
.Select(
Projections.Alias(Projections.Property(t…

csano
- 13,266
- 2
- 28
- 45
8
votes
1 answer
GROUP BY and HAVING clauses in nHibernate QueryOver
I'm trying to write this specific sql query in nHibernate QueryOver language, which I am not very familiar with:
SELECT MessageThreadId FROM MessageThreadAccesses
WHERE ProfileId IN (arr)
GROUP BY MessageThreadId
HAVING COUNT(MessageThreadId) =…

Matej
- 165
- 3
- 7
8
votes
1 answer
Join multiple tables with NHibernate and QueryOver
I have this tables:
Person -> PersonFavorites, PersonCompany
PersonCompany -> Company
I have now to do the following select with NHibernate and QueryOver:
select * from Person
inner join PersonFavorites on Person.Id = PersonFavorites.PersonId
…

BennoDual
- 5,865
- 15
- 67
- 153