Questions tagged [queryover]

QueryOver is a strongly-typed fluent-like wrapper on top of NHibernate ICritieria, a database-agnostic query API that supports query composition.

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 result = …
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() This query works as expected however I now have a…
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…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/icriteria" class="post-tag grid--cell" title="show questions tagged 'icriteria'" rel="tag">icriteria</a> <a href="../../questions/tagged/queryover" class="post-tag grid--cell" title="show questions tagged 'queryover'" rel="tag">queryover</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 23 '11 at 07:34">asked Apr 23 '11 at 07:34</time> <a href="../../users/184131/csano" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/184131.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="csano" /> </a> <div class="s-user-card--info"> <a href="../../users/184131/csano" class="s-user-card--link">csano</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13,266</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="28 silver badges">28</li> <li class="s-award-bling s-award-bling__bronze" title="45 bronze badges">45</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-14602005"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>8</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/14602005/group-by-and-having-clauses-in-nhibernate-queryover" class="question-hyperlink">GROUP BY and HAVING clauses in nHibernate QueryOver</a></h3> <div class="excerpt">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) =…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/c#" class="post-tag grid--cell" title="show questions tagged 'c#'" rel="tag">c#</a> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/queryover" class="post-tag grid--cell" title="show questions tagged 'queryover'" rel="tag">queryover</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 30 '13 at 10:40">asked Jan 30 '13 at 10:40</time> <a href="../../users/1654884/matej" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1654884.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Matej" /> </a> <div class="s-user-card--info"> <a href="../../users/1654884/matej" class="s-user-card--link">Matej</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">165</li> <li class="s-award-bling s-award-bling__silver" title="3 silver badges">3</li> <li class="s-award-bling s-award-bling__bronze" title="7 bronze badges">7</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12652087"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>8</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12652087/join-multiple-tables-with-nhibernate-and-queryover" class="question-hyperlink">Join multiple tables with NHibernate and QueryOver</a></h3> <div class="excerpt">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 …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/nhibernate" class="post-tag grid--cell" title="show questions tagged 'nhibernate'" rel="tag">nhibernate</a> <a href="../../questions/tagged/queryover" class="post-tag grid--cell" title="show questions tagged 'queryover'" rel="tag">queryover</a> <a href="../../questions/tagged/nhibernate-3" class="post-tag grid--cell" title="show questions tagged 'nhibernate-3'" rel="tag">nhibernate-3</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 29 '12 at 10:50">asked Sep 29 '12 at 10:50</time> <a href="../../users/2042829/bennodual" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2042829.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="BennoDual" /> </a> <div class="s-user-card--info"> <a href="../../users/2042829/bennodual" class="s-user-card--link">BennoDual</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">5,865</li> <li class="s-award-bling s-award-bling__gold" title="15 gold badges">15</li> <li class="s-award-bling s-award-bling__silver" title="67 silver badges">67</li> <li class="s-award-bling s-award-bling__bronze" title="153 bronze badges">153</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=2" rel="prev" title="Go to page 2">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=2" rel="" title="Go to page 2">2</a> <div class="s-pagination--item is-selected">3</div> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=49" rel="" title="Go to page 49">49</a> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=50" rel="" title="Go to page 50">50</a> <a class="s-pagination--item" href="../../questions/tagged/queryover_page=4" rel="next" title="Go to page 4"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>