A provider for NHibernate library for .NET Framework which allows to use LINQ queries. Available since version 3.0.
Questions tagged [linq-to-nhibernate]
629 questions
3
votes
3 answers
How to return first object of a collection from its parent
I am looking to do the following with a single database query if possible.
public class Location
{
public string URL {get;set;}
public IList Pages {get;set;}
}
Page firstPage = Session.Linq()
.Where(location…

Dave The Ninja
- 141
- 8
3
votes
2 answers
Success with WCF Data Services (OData) with NHibernate?
I'm working on a CQRS-style system with commands processed with NSericeBus and queries provided through a read-only OData feed.
We would like to have the WCF Data Services feed backed by NHibernate so we can have control over how our data appears in…

Eric Farr
- 2,683
- 21
- 30
3
votes
1 answer
Group by using linq with NHibernate 3.0
As far as I know group by has only been added in NHibernate 3.0, but even when using version 3, I can't get group by to work.
I have tried to do the following query:
Session.Query().GroupBy(gbftr
=> gbftr.Tag).OrderByDescending(obftr =>…

Dofs
- 17,737
- 28
- 75
- 123
3
votes
2 answers
Eager loading related entities from a table-valued function in NHibernate
So I have a table-valued function in my dabatase that does some heavy and complex query based on several parameters, and returns for example three columns: OrderId, SomeCalc1, SomeCalc2.
Now in order to translate this into NHibernate, the only…

Pinx0
- 1,248
- 17
- 28
3
votes
2 answers
How to order a NHibernate 3.0 Linq query based on a supplied property name
I'm trying to order my NHibernate 3.0 Linq query dynamically, based on a column name stored in a string variable.
// The value of this variable can be the name of any property of Document.
string columnName = "column1";
var query = from n in…

Sandor Drieënhuizen
- 6,310
- 5
- 37
- 80
3
votes
1 answer
Compiled LINQ queries - NHibernate
Looking at this link shows me that compiled queries can be used to improve performance in Linq to SQL apps (I've seen other examples in Entity…

nick
- 1,477
- 2
- 20
- 29
3
votes
0 answers
NH QueryOver FetchMany Exception
I am trying to query a parent User and then their UserRoleMappings. I have something similar to the below statement:
Dim userObj As User = session.Queryable(Of User)().Where(Function(x) x.username.Equals("someone")).FetchMany(Function(y)…

ash
- 45
- 4
3
votes
5 answers
LINQ to NHibernate: could not resolve property
Fluent nHibernate using nHibernate v. 2.1.2.4, nHibernate.Linq v. 1.1.0.1001, and Fluent NHibernate v. 1.1.0.685.
I have a domain object with a DateTime field called DateOfEvent. This is an actual date/time field in the database. I've also added 2…

StephenPAdams
- 2,797
- 2
- 30
- 49
3
votes
1 answer
Nhibernate Linq & operator RegisterFunction Firebird
I am using NHibernate with Firebird and would like to create the bitwise and operator to the Firebird function bin_and(a, b)
Something like this:
var result = customers.Where(c => (c.StatusValue & 3) > 0);
The above query will result in something…

Franki1986
- 1,320
- 1
- 15
- 40
3
votes
2 answers
Linq to NHibernate - ordering anonymous type
I am using Nhibernate v2.1.2.4000. With many-to-many relationship between Posts an Tags I have the query:
tags
.Select(t => new { Name = t.Name, Count = t.Posts.Count })
.OrderBy(x => x.Count);
Ordering anonymous type fails (reference not set to…

rovsen
- 4,932
- 5
- 38
- 60
3
votes
1 answer
How can I mock or similarly inject a replacement for the query extension method applied to an NHibernate Session
I am trying to mock out or similar the Query extension method applied to an nhibernate-3 session. Similar to the following...
public IQueryable GetEntities
{
return entities = Session.Query();
}
Where the Query extension method…

Aim Kai
- 2,934
- 1
- 22
- 34
3
votes
1 answer
nhibernate linq: projection to DTO and columns
I've recently upgraded my Linq provider to the new AST one. (NH3 on NuGet)
With the previous provider I was using linq to do "inline projections
to my DTO"
e.g.
from o in Session.Query()
select new MyObjectDTO {
Name = o.Name,…

Chris
- 1,241
- 1
- 14
- 33
3
votes
3 answers
NHibernate Linq Eager Loading with generic repository
Currently we are using a generic repository for all our entities that exposes an IQueryable (using NH3 linq support) that is then used by our service layer to construct specific queries.
I now need to eagerly load an association. Is there any way I…

Ben Foster
- 34,340
- 40
- 176
- 285
3
votes
1 answer
NHibernate .Query returning stale data
This is my unit test (it's quite meaningless but proves a point
Config entity = new Config("key", "value");
Session.SaveOrUpdate(entity);
Config config = Session.Query().SingleOrDefault(c => c.Key ==…

Paul
- 9,409
- 13
- 64
- 113
3
votes
0 answers
NHibernate how to use ToFuture in more complex queries
I have following data model
I would like to retrieve from database one client with its whole organization structure using nHibernate Future.
I tried something like this:
public DBClient GetOrganizationStructure(long clientOid)
{
…

user2126375
- 1,594
- 12
- 29