Questions tagged [nhibernate-projections]

83 questions
1
vote
1 answer

NHibernate OrderBy Projection on Child Objects

I have 2 entities OrganisationMember and User An OrganisationMember has a object Property called User of type User. I'm trying to write an NHibernate Query which will do a case insensitive sory by the User.Email property... (users typing emails into…
Eoin Campbell
  • 43,500
  • 17
  • 101
  • 157
1
vote
1 answer

NHibernate projection: How to create AliasToBean projection?

I am trying to convert this inefficient query into one that projects into a dto. Original query looks like this: var flatFeePolicies = _session.QueryOver(() => flatChargeAccessFeeAlias) …
epitka
  • 17,275
  • 20
  • 88
  • 141
1
vote
1 answer

How to get nested objects using ICriteria Projections

I have data model like this: class Hand { public int id; ... } class Person { public int id; public string name; public IList hands; ... } To get data from database, I do this: ICriteria criteria =…
Jarda
  • 566
  • 1
  • 9
  • 33
1
vote
2 answers

nHibernate projection - paging and distinct

The high level problem I am trying to solve is de-duplicated paging when searching for things that may exist in child collections. The approach I'm taking is by creating a distinct Projection, containing the information pertinent to my DTO. I also…
1
vote
1 answer

Can you project multiple aggregates from a single QueryOver

I can create a single aggregate projection on a collection of entities example Return the number of shops that are active But is there a way to project the number of a bunch of different summations in the same query over? example number of shops…
pghtech
  • 3,642
  • 11
  • 48
  • 73
1
vote
1 answer

Trying to create QueryOver for many to many relationship with projections

I have two tables (Orders, Transactions) and a TransactionsOrders lookup table that just retains an OrderId and TransactionsId columns. There can be multiple transactions for an order if a transaction failed (n) times. And the Order object doesn't…
pghtech
  • 3,642
  • 11
  • 48
  • 73
0
votes
1 answer

Projection, flattening out structure

I'm trying to do a projection with these two classes: public class SomeClass { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual IList Languages { get; set; } } public class…
Pelle
  • 2,755
  • 7
  • 42
  • 49
0
votes
1 answer

Loading navigation properties in NHibernate 3.2

I have these entities: public class Post { public virtual int Id { get; set; } public virtual ICollection Tags { get; set; } public virtual ICollection Comments { get; set; } } public class Tag { public virtual int Id…
0
votes
1 answer

NHibernate Criteria API error with create alias and a collection of projections

I'm tasked with generating a list of member data using the NHibernate Criteria API. I need to incorporate paging and filtering based on checkboxes in the UI. What makes this a bit more complex is that I'm not just fetching data from one entity, but…
0
votes
1 answer

Querying into projection

I have 2 tables in a one-to-many mapping, layoutFeature and layoutPadData. Parent table layoutFeature has 2 columns: layoutId (Pkey) and colorHex. Child table layoutPadData has 5 columns: layoutId (Fkey), padId (Pkey), longitude, latitude,…
0
votes
2 answers

nHibernate QueryOver Projects - are Select and Where the same thing?

Using nHibernate QueryOver, if I want to enforce a projection for performance, are "Select" and "Where" the same thing? In other words, will .. var member = session.QueryOver() .Select( projections => projections.Email ==…
Ciel
  • 17,312
  • 21
  • 104
  • 199
0
votes
1 answer

projection of type average(datediff) always returns 0.0

This is very puzzling; the generated SQL is perfectly good, and I get correct results when running it manually. However, somewhere in the transformation process the 'AverageTime' field is set to 0.0 instead of the correct result. my query: var…
J. Ed
  • 6,692
  • 4
  • 39
  • 55
0
votes
1 answer

hibernate projection for one-to-many mapping set of objects

I have a USER object which has many fields having one-to-many mapping with PERMISSION object as well. I want to fetch only few fields of user with a set of permissions as well. my code is public class USER { private Integer id; private String…
oOXAam
  • 237
  • 1
  • 6
  • 20
0
votes
1 answer

How to map nested projections with native query

I want to map my query result to RequestProjection interface values. The following code works and return request id and submission date. I need to return worker name too. I have tried r.worker_name AS workerName and r.worker_name AS worker_name and…
0
votes
1 answer

Hibernate criteria setFetchMode gets ignored using projections

Im trying to eagerly fetch all contentItems to avoid the N + 1 lazy initialization problem but my setfetchmode call gets ignored by hibernate when using projections. While not using projections it works as expected. What am I doing wrong? The…
Merv
  • 1,039
  • 2
  • 12
  • 22