Questions tagged [nhibernate-projections]
83 questions
50
votes
4 answers
When to use Hibernate projections?
I am a little confused about Hibernate's projections and criteria. When to use projections and when to use criteria?

reddy
- 701
- 2
- 10
- 10
30
votes
3 answers
Can someone better explain what 'Projections' are in nHibernate?
As a new user of nHibernate and its utility library, fluent nhibernate, I am trying to learn enough to be dangerous with a good database.
I am having an exceptionally great deal of difficulty understanding the concept of Projections. Specifically,…

Derek
- 769
- 1
- 7
- 14
8
votes
2 answers
gorm projection and loss of metainformation
When using projection on the properties, the result is returned as the list with the elements in the same sequence as that defined in the projections block. At the same time the property names are missing from the list and that is really…

rks
- 451
- 1
- 8
- 16
6
votes
2 answers
Are there any arithmetic operation projections in NHibernate?
I would like to get this SQL from NHibernate:
SELECT SUM(color_pages) * SUM(total_pages)
FROM connector_log_entry
GROUP BY department_name
But I can't find any arithmetic operation (*) projections anywhere.
This is the code that I have so…

Andrej Slivko
- 1,236
- 2
- 12
- 27
4
votes
0 answers
Concatenate fields using NHibernate projections
Using the accepted answer to this question I have been able to concatenate two fields using ICriteria and projections. I have ended up with
return session.CreateCriteria()
.CreateAlias("USState","USState",…

Steve Mallory
- 4,245
- 1
- 28
- 31
4
votes
3 answers
NHibernate projecting child entities into parent properties with Linq or QueryOver
Maybe it's simple but I'm stuck with it and I didn't find any answer on how it could be done. I have a parent entity User with a collection of child entities Operations. These two entities are just for UI so they are a kinf of views. Here is the…

Tomasz Jaskuλa
- 15,723
- 5
- 46
- 73
4
votes
1 answer
Can I use NHibernate Criteria to project an entity and its child collection onto a class?
I'm using NH Criteria to retrieve an entity and project selective fields onto a custom class (a bit like projecting data onto a ViewModel for display on an MVC view).
This is easy enough using ProjectionList:
var emailCriteria =…

Coding Headache
- 101
- 7
4
votes
2 answers
NHibernate Projection queries group by date
I want to write a Projection query in NHibernate that groups records by date and counts "Tax" field value for those records. My question is that the database has the value as DateTime, how will I group records just by date and not time.Below is my…

developer
- 5,178
- 11
- 47
- 72
4
votes
4 answers
Is it possible to use aggregate functions and property in Projections, Criteria, Grails?
I am using Grails Criteria (similar to hibernate criteria) to get a list of Student who got highest grade in each division from the given table. And I want ONLY Name, Division and Grade fields.
Name | Division | Grade |…

Khaino
- 3,774
- 1
- 27
- 36
4
votes
2 answers
NHibernate Criteria select items by the group by and sum of itemid within another table
public class SearchText
{
public virtual int Id { get; set; }
public virtual string Text { get; set; }
}
public class SearchTextLog
{
public virtual int Id { get; set; }
public virtual SearchText SearchText { get; set; }
public…

ctrlplusb
- 12,847
- 6
- 55
- 57
4
votes
1 answer
Nhibernate count distinct (based on multiple columns)
Basically, i have been trying to do this (count distinct based on two columns):
select count(distinct(checksum(TableA.PropertyA, TableB.PropertyB)))
from TableA
left outer join TableB
on TableA.TableBId = TableB.Id
where PropertyA like…

raberana
- 11,739
- 18
- 69
- 95
4
votes
3 answers
NHibernate: Projecting child entities into parent properties throws an exception
I have the following parent entity Department which contains a collection of child entities Sections
public class Department
{
private Iesi.Collections.Generic.ISet _sections;
public Department()
{
_sections = new…

kagundajm
- 1,152
- 1
- 15
- 26
3
votes
1 answer
NHibernate projection, AutoMapping, IPagedList, how to?
I have these entities and models:
ENTITIES:
public class BlogPost {
public virtual int Id { get; set; }
public virtual IList Keywords { get; set; }
public virtual IList Comments { get; set; }
}
public class…

amiry jd
- 27,021
- 30
- 116
- 215
3
votes
1 answer
NHibernate Nested Projection
Not sure this is even possible but I'll explain anyway.
I have a custom projection for doing simple arithmetic in a query which works perfectly in a single projection.
namespace Custom.Projections
{
using System.Collections.Generic;
using…

dylman79
- 115
- 7
3
votes
2 answers
How to create a subquery Projection, give it an Alias, and sort by the Alias in NHibernate with the Criteria API
forum.hibernate.org/viewtopic.php?p=2378849
one of the posters gives this answer:
You need to create a Projection (...), give it an alias and you can then sort by the alias.
No time to post the details but I'm pretty sure that would work.
Could…

andy
- 8,775
- 13
- 77
- 122