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
14
votes
1 answer

How to do subqueries in nhibernate?

I need to do a subquery on a sub collection but I can't get it to work. I tried this Task tAlias = null; List result = session.QueryOver(() => tAlias) …
chobo2
  • 83,322
  • 195
  • 530
  • 832
14
votes
3 answers

NHibernate lazy loading nested collections with futures to avoid N+1 problem

I have an object model that looks like this (pseudo code): class Product { public ISet Recommendations {get; set;} public ISet Recommenders {get; set;} public ISet Images {get; set; } } When I load a given…
Nicholas Cloud
  • 1,564
  • 1
  • 13
  • 19
14
votes
3 answers

NHibernate 3. Alternatives to "ThenFetch" in QueryOver

I'm using NHibernate 3.0 with both the LINQ provider and QueryOver. Sometimes I want to eager load related data, and there comes the method "Fetch" to the rescue, both in LINQ and QueryOver. Now I have a special scenario where I want to eager load a…
psousa
  • 6,676
  • 1
  • 32
  • 44
13
votes
3 answers

NHibernate QueryOver: How to join unrelated entities?

I have the following query working which gets the results I want: int associatedId = 123; MyObject alias = null; var subQuery = QueryOver.Of() .Where(view => view.AssociatedId == associatedId) .And(view => view.ObjectId ==…
David McClelland
  • 2,686
  • 4
  • 28
  • 37
12
votes
2 answers

Queryover where id is not in list

I have been struggling with this for a while, so I hope some of you QueryOver experts can help. I have a list of blog posts. You can vote on each blog post, and I would like (among other) to recieve a list of posts where the user hasn't voted. First…
Dofs
  • 17,737
  • 28
  • 75
  • 123
12
votes
1 answer

simple QueryOver : Unrecognised method call

I have a simple QueryOver var q = SessionInstance.QueryOver().Where(p => p.Number.Equals(number)); Number field type is int. This query has a runtime error by this message: Unrecognised method call: System.Int32:Boolean Equals(Int32)
Ehsan
  • 3,431
  • 8
  • 50
  • 70
12
votes
1 answer

How to "Select" with nhibernate queryover

I want to use query over to give me back an object public class TaskMap : ClassMap { public TaskMap() { Table("Tasks"); Id(x => x.TaskId); Map(x =>…
chobo2
  • 83,322
  • 195
  • 530
  • 832
12
votes
1 answer

NHibernate QueryOver: Get a row count with group by in a subquery

I'm trying to get a count from a query with a group by and just can't figure out how to translate the SQL I want into NHibernate's QueryOver syntax. This is the SQL: select count(*) from (select Email from Entry where (conditions...) …
mmacaulay
  • 3,049
  • 23
  • 27
12
votes
3 answers

How select referenced entity in nhibernate queryover

I Have a entity with a property referencing other entity (ReferenceEntity in examples). With HQL i can do this: select e.ReferenceEntity from Entity e where e.Id = :entityId NHibernate will give me the ReferenceEntity instance without lazy. With…
12
votes
3 answers

specifying fetch strategy (select, join, etc) in nhibernate queryover query

I am trying to create a query using QueryOver, which will fetch a collection using the Select or SubSelect mode. The entity in question is Track. I want to load a collection called TrackPrices, and I am doing this in the query: q = q.Fetch(item =>…
Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
12
votes
1 answer

Help with QueryOver and WhereExists

I have a problem. I have Persons and Cats. Each Person has some Cats (there is a foreign key in Cats that points to the primary key in Persons). Each Cat has an Age. I want to select the Persons that have "Old" Cats. I want ALL the Cats of these…
xanatos
  • 109,618
  • 12
  • 197
  • 280
12
votes
1 answer

Use OR Clause in queryover in NHibernate

I am using Nhibernate. I am writing query through queryover method. I am able to write and clause as in code below. Its working fine. db.QueryOver(Of Users)() .Where(Function(x) x.Role = "Guest") .And(Function(x) x.Block = 0) .And(Function(x)…
Muhammad Ali Hassan
  • 960
  • 2
  • 12
  • 29
11
votes
2 answers

NHibernate QueryOver Subquery

I've looked at the similar questions, but can't find a simple explanation. I could have missed it, but I promise I looked. Actually I can't even find the documentation other than a single blog post that glosses over everything rapidly and assumes…
Carl Bussema
  • 1,684
  • 2
  • 17
  • 35
11
votes
2 answers

nhibernate queryover join with subquery to get aggregate column

I have been searching for several hours now how to do this, but can't seem to find anything to help me. Here is the database model: This is the SQL query I am trying to run: SELECT b.*, a.Assignments FROM Branch b LEFT JOIN ( SELECT…
noir
  • 566
  • 2
  • 5
  • 19
11
votes
2 answers

Can I use SQL functions in NHibernate QueryOver?

I have been searching the internet and can't find an example on how to use the queryover of nhibernate 3.0 For example I would like to use the string functions on the where clause of the queryover ex: var item = Query.Where(x => x.Name.ToLower() ==…
Ruben Monteiro
  • 315
  • 3
  • 15
1
2
3
49 50