Questions tagged [linq-to-nhibernate]

A provider for NHibernate library for .NET Framework which allows to use LINQ queries. Available since version 3.0.

629 questions
15
votes
4 answers

How do I wrap Linq2NHibernate's .Fetch and .ThenFetch inside my abstract repository?

I'm using a generic repository that exposes an IQueryable like this: public IQueryable AllEntities { get { return session.Query(); } } I can query like this: var results = (from e in repository.AllEntities …
Scott Whitlock
  • 13,739
  • 7
  • 65
  • 114
14
votes
1 answer

NHibernate Linq Query is 3x slower than HQL

I have a simple test that runs a query 5000 times. The linq version of the query takes over 3 times the HQL and the cached Linq version is significantly slower than the cached version of HQL HQL: session.CreateQuery(String.Format("from Episode where…
kay.one
  • 7,622
  • 6
  • 55
  • 74
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
14
votes
5 answers

Does NHibernate LINQ support ToLower() in Where() clauses?

I have an entity and its mapping: public class Test { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual string Description { get; set; } } public class TestMap : EntityMap { public…
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
14
votes
2 answers

How to use join with multiple conditions in linq-to-Nhibernate

I have two classes (Request & RequestDetail). I need to a Linq To NHibernatequery between two classes by join. var q = SessionInstance.Query() .Where(x => x.State == "Init"); var q2 = SessionInstance.Query(); q2 =…
Ehsan
  • 3,431
  • 8
  • 50
  • 70
12
votes
3 answers

NHibernate.Linq and MultiCriteria

Anybody know of a way to batch NHibernate queries using NHibernate.Linq like you can do with MultiCriteria and ICriteria objects? With MultiCriteria I can create something like this: var crit = session.CreateMultiCriteria() …
Andrew Hanson
  • 2,005
  • 3
  • 15
  • 18
12
votes
4 answers

strange linq to nhibernate issue, Invalid cast from 'System.Int32'

Calling Get in the following code works fine: public class ContractService : IContractService { private readonly IRepository repository; public ContractService(IRepository repository) { this.repository =…
Andrew Bullock
  • 36,616
  • 34
  • 155
  • 231
12
votes
4 answers

Linq to NHibernate : is it mature?

I'm thinking about using Linq to NHibernate in an upcoming project, so I'd like some feedback about it. I found this identical question asked in February, and it seemed that Linq to NHibernate was not very mature at this time... Has it improved…
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
12
votes
4 answers

How to set timeout for NHibernate LINQ statement

I am using Fluent NHibernate for my ORM. In doing so I am trying to use the NHibernate LINQ syntax to fetch a set of data with the power of LINQ. The code I have works and executes correctly with the exception being that a timeout is thrown if it…
Brandon Wenzel
  • 435
  • 1
  • 3
  • 11
10
votes
1 answer

fluent nhibernate not supported exception newexpression

can anyone help me figure out what I'm doing wrong. I'm new to nhibernate and I'm finding it quite hard to really get comfortable with it. I have this query: var results2 = (from purchase in _session.Query() …
Leon
  • 141
  • 3
10
votes
1 answer

QueryOver statement for selecting N rows with descending DateTime order

I am trying to write QueryOver statement for selecting N rows in the descending time order. session.QueryOver().Take(10).OrderBy(x=>x.DateInserted); Unfortunately this is not at all working. Is there any way to sort it out?
navule
  • 3,212
  • 2
  • 36
  • 54
9
votes
2 answers

NHibernate 3.x deletes child entities when combining LINQ paging, many-to-many, and subselect fetch

Our application has the concept of Stories and the concept of Tags. A story can have many tags applied to it, and a tag can be applied to many stories, making the relationship many-to-many. The two tables, Stories and Tags are bridged with a third,…
Nate Kohari
  • 2,216
  • 17
  • 13
9
votes
2 answers

NHibernate.Linq - How well does it work?

we're starting a new project using NHibernate, and considering using NHibernate.Linq (The embedded version in 3.0, not the contrib project). I'm aware that this is a relatively recent addition. Has anyone used the current LINQ for NHibernate much?…
Paul
  • 6,188
  • 1
  • 41
  • 63
9
votes
4 answers

Is this the right way of using ThenFetch() to load multiple collections?

I'm trying to load all the collections eagerly, using NHibernate 3 alpha 1. I'm wondering if this the right way of using ThenFetch()? Properties with plural names are collections. The others are just a single object. IQueryable
esegura
  • 493
  • 4
  • 12
9
votes
1 answer

NHibernate uses wrong column type for LINQ contains query (varchar to nvarchar)

I'm having an issue with NHibernate 3.3.3 against SQL Server using NVARCHAR as a parameter against a VARCHAR column for LIKE queries created from a string.Contains() function in a LINQ expression. I have Fluent mappings which tell NHibernate that…
StuffOfInterest
  • 518
  • 3
  • 11
1
2
3
41 42