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
4
votes
1 answer
Linq to NHibernate Distinct() "Expression type not supported" error
I've got the following code:
var data = (from v in this.GetSession().Query()
where v.WorkCellId == "13"
select
new WorkCellLoadGraphData
…

DavidS
- 2,179
- 4
- 26
- 44
4
votes
1 answer
Can't retrieve Group By entities or by composite keys with Nhibernate's Linq
I am trying to perform a group by Linq query with NH3.
Knowing the underling SQL difficulties I know it's not possible but Ideally I would like to do the group by an entity and have it retrieved in it's entirety.
Something like:
var list = from…

Variant
- 17,279
- 4
- 40
- 65
4
votes
2 answers
NHibernate 3 LINQ : How to filter IQueryable to select only objects of class T and its subclasses?
I want to upgrade my application to use NHiberante 3 instead of NHibernate 2.1.2 but faced some problems with the new LINQ provider. This question is about one of them. Assume that I have a following hierarchy of classes:
public abstract class…

Anton Nikolayev
- 43
- 1
- 4
4
votes
1 answer
Linq to NHibernate extensibility for custom string query operations?
I would like to be able to use custom string querying within my NHibernate Linq expressions. Let's say for example (and this is just an example) I would like to be able to select entities containing a property which is an anagram of a particular…

David
- 15,750
- 22
- 90
- 150
4
votes
1 answer
NHibernate 3CR1: Fetching strategy problems
Continuation to the previous question, I tried to avoid the problem another way:
Just for the reminder:
My database schema is described below:
Form <-> Log
<--->>Seller1
<--->>Seller2
<--->>Seller3
I have a major entity (Form), one to
one…

ari
- 331
- 1
- 4
- 19
4
votes
1 answer
Linq2NHibernate - Only Left Joins?
Really quick question..
Does Linq2NHibernate always create a left join to retrieve relationships? Is there a way that I can get an inner one instead?
Thank you in advance.
Filipe

jfneis
- 2,139
- 18
- 31
4
votes
2 answers
NHibernate 3 - extending Linq provider BaseHqlGeneratorForMethod.BuildHql problem
I want to extend the default LINQ provider for NHibernate 3 with methods of my own. I want to be able to use some methods from my POCOs. I have a component named Range which is used quite often in many of my POCOs. This nhibernate component class…

Vasea
- 5,043
- 2
- 26
- 30
4
votes
2 answers
Composite Id's and Restrictions.IdEq or with comparison in Linq not working as expected
I have an entity where a composite id is used. I changed to code to make use of wrapping the composite id in a seperate key class. I expected that with Linq I could do a comparison on key object and with the Criteria API to use Restrictions.IdEq but…

Ramon Smits
- 2,482
- 1
- 18
- 20
4
votes
1 answer
NHibernate/LINQ - Aggregate query on subcollection
Querying child collections has been a recurring issue in our applications where we use NHibernate (via LINQ). I want to figure out how to do it right. I just tried forever to get this query to work efficiently using LINQ, and gave up. Can someone…

Luke
- 2,101
- 19
- 21
4
votes
1 answer
Nhibernate Linq 3 In Clause
It seems that a In clause is not working properly with Linq 3.0 (trunk)
I tried following:
var l = session.Query.Where(p => searchGroups.Contains(p.ID)).Select(r=>r);
I get an exception that says that
the Binary operator for…

DennisR
- 41
- 2
4
votes
1 answer
When using nhibernate, how can I do a ThenFetch() and then bring in mulitple Properties / joins?
I have the following code that works as part of a Fluent NHibernate query
session.Query()
.Where(r=>r.IsActive)
.FetchMany(r => r.ProjectDependencies)
.ThenFetch(r => r.DependencyProject)
.ThenFetch(r =>…

leora
- 188,729
- 360
- 878
- 1,366
4
votes
2 answers
Linq to NHibernate - The method Cos is not implemented
In Linq to NHibernate I'm trying to return businesses within a certain distance of a user. Here is what I have so far:
var query = from b in ActiveRecordLinq.AsQueryable()
where (3959 * Math.Acos(Math.Cos((Math.PI *…

Justin
- 17,670
- 38
- 132
- 201
4
votes
2 answers
NHibernate Linq Query with Projection and Count error
I have the following query:
var list = repositoy.Query.Select(domain => new MyDto()
{
Id = domain.Id,
StringComma = string.Join(",", domain.MyList.Select(y => y.Name))
});
That works great:
list.ToList();
But if I try to get…

Paul
- 12,359
- 20
- 64
- 101
4
votes
4 answers
Where to put NHibernate query logic?
I am trying to set up proper domain architecture using Fluent NHibernate and Linq to NHibernate. I have my controllers calling my Repository classes, which do the NHibernate thang under the hood and pass back ICollections of data. This seems to…

Mike Cole
- 14,474
- 28
- 114
- 194
4
votes
3 answers
Why ordinary laws in evaluating boolean expression does not fit into LINQ?
In such a code:
if (insuranceNumberSearch == null
? true
: ei.InsuranceNumber.Contains(insuranceNumberSearch.Trim()))
doSomething();
where insuranceNumberSearch is null, remaining expression is not null while in following code:
var…

Afshar Mohebi
- 10,479
- 17
- 82
- 126