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
91
votes
2 answers

What is the difference between JoinQueryOver and JoinAlias?

I need to know what is the difference between JoinQueryOver and JoinAlias, and when to use each?
Luka
  • 4,075
  • 3
  • 35
  • 61
54
votes
3 answers

NHibernate using QueryOver with WHERE IN

I would create a QueryOver like this SELECT * FROM Table WHERE Field IN (1,2,3,4,5) I've tried with Contains method but I've encountered the Exception "System.Exception: Unrecognised method call: System.String:Boolean…
Faber
  • 2,194
  • 2
  • 27
  • 36
51
votes
4 answers

How to get a distinct result with nHibernate and QueryOver API?

I have this Repository method public IList ListMessagesBy(string text, IList tags, int pageIndex, out int count, out int pageSize) { pageSize = 10; var likeString = string.Format("%{0}%", text); var…
Anders
  • 17,306
  • 10
  • 76
  • 144
51
votes
3 answers

queryover and (x like 'a' or y like 'a')

Hi Is there any elegant way of combining 'like' and 'or' when i'm using queryover API? for 'like' there is something like: query.WhereRestrictionOn(x=>x.Code).IsLike(codePart) for 'or' i can do something like: query.Where( x=>x.Code == codePart…
buddy
  • 725
  • 1
  • 6
  • 9
40
votes
1 answer

How can I recreate this complex SQL Query using NHibernate QueryOver?

Imagine the following (simplified) database layout: We have many "holiday" records that relate to going to a particular Accommodation on a certain date etc. I would like to pull from the database the "best" holiday going to each accommodation (i.e.…
Chris Haines
  • 6,445
  • 5
  • 49
  • 62
36
votes
2 answers

Eagerly fetch multiple collection properties (using QueryOver/Linq)?

I found 2 similar questions: Multiple Fetches in linq to nhibernate Is this the right way of using ThenFetch() to load multiple collections? According to this page: Be careful not to eagerly fetch multiple collection properties at the same…
user593358
32
votes
5 answers

NHibernate 3.0: No FirstOrDefault() with QueryOver?

I am playing with FluentNHibernate and NH 3.0, using the LINQ provider and the new QueryOver syntax. Now with QueryOver I want to get an item (called result) with a timestamp value as close as possible to a given value, but not greater: Result…
Marcel
  • 15,039
  • 20
  • 92
  • 150
30
votes
4 answers

How do I get row count using the NHibernate QueryOver api?

I'm using the QueryOver api that is part of NHibernate 3.x. I would like to get a row count, but the method I'm using returns all objects and then gets the count of the collection. Is there a way to just return an integer/long value of the number…
Jim Geurts
  • 20,189
  • 23
  • 95
  • 116
27
votes
1 answer

How to create hibernate composite key using annotations

I am trying to use hibernate annotations to insert data to a MySQL database table which doesn't have a primary key defined. However the fact is 2 fields of that table together are unique in the table.how can i achieve the same using hibernate…
edaklij
  • 4,121
  • 11
  • 31
  • 43
26
votes
1 answer

QueryOver Or with Subquery

IHave the following NHibernate query using a subquery: NHContext.Session.QueryOver() .WithSubquery.WhereProperty(x => x.ItemId).In(QueryOver.Of().Where(x => x.AFlag).Select(x => x.ItemId)) …
Gunner
  • 907
  • 2
  • 9
  • 17
22
votes
4 answers

Search text contains with QueryOver

I'm trying to do this : var list = Session.QueryOver() .Where(x => x.LastName.Contains(searchText)) .List(); but I get this error : Unrecognised method call: System.String:Boolean Contains(System.String) Do you have an idea…
TheBoubou
  • 19,487
  • 54
  • 148
  • 236
19
votes
2 answers

How can you avoid NHibernate N+1 with composite key

EDIT I remade an entire project for this one problem. And thus, I remade the question. I want to be able to efficiently avoid N+1 and Cartesian joins joining together a 4 level deep entity with a composite key on the third level. I am looking for…
BradLaney
  • 2,384
  • 1
  • 19
  • 28
19
votes
2 answers

Fluent NHibernate "Could not resolve property"

I have read a lot of the questions about that same error but none since to match my exact problem. I'm trying to access the property of an object, itself part of a root object, using Fluent NHibernate. Some answers say I need to use projections,…
Astaar
  • 5,858
  • 8
  • 40
  • 57
17
votes
1 answer

QueryOver IN Clause?

I want to simulate this query: SELECT * FROM FOO WHERE ID IN (1,2,3) How can I do this in FNH? var ids = new List{1,2,3}; var results = session.QueryOver().Where( x=> ids.Contains(x.id) ); But that does not work, just gives me an…
Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
16
votes
1 answer

NHibernate QueryOver with MaxResult, Group By and Order By

I'm trying to convert a SQL query to NHibernate QueryOver syntax, but I don't understand how to sort by the count projection. This is what the SQL Query looks like: select top 10 v.intVoteUserID, COUNT(v.intVoteUserID) from Group_MessageVotes…
Johan Nordberg
  • 3,621
  • 4
  • 33
  • 58
1
2 3
49 50