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
6
votes
1 answer

Select n+1 problem

Foo has Title. Bar references Foo. I have a collection with Bars. I need a collection with Foo.Title. If i have 10 bars in collection, i'll call db 10 times. bars.Select(x=>x.Foo.Title) At the moment this (using NHibernate Linq and i don't want…
6
votes
1 answer

NHibernate - Query misses the query cache after saving a new entity

I have NHibernate (with NHibernate.Linq and Fluent NHibernate) set up with query caching. Everything works fine until I do a session.Save(new Widget()) (i.e. SQL INSERT). After that point, all queries on that type Widget miss the query cache.…
Joel Verhagen
  • 5,110
  • 4
  • 38
  • 47
6
votes
3 answers

Fetching records by date with only day part comparison using nhibernate

I would like to fetch all records from particular day, no matter what time is associated with those records. So far I have method like this: public IQueryable QueryByDay(DateTime day) { DateTime from = day.Date; DateTime to =…
0lukasz0
  • 3,155
  • 1
  • 24
  • 40
5
votes
1 answer

Nhibernate.Linq: Restricting query results with Where(Expression>)

I query my Database using NHibernate. Now I need to restrict the data being selected using a Predicate. So far I found out (Google driven development at its best) that something like this is possible using Expressions and NHibernate.Linq. Here's…
Sebastian Edelmeier
  • 4,095
  • 3
  • 39
  • 60
5
votes
1 answer

Querying unmapped properties in nhibernate

I am working with Linq-To-NHibernate. I need to use some properties that is not mapped to columns. For example Repository .Find() .Select(p => new PersonModel() { Id = p.Id, FullName= p.FullName,Position = p.Position }); The position…
user39880
5
votes
2 answers

The LastResultOperator result operator is not current supported

I have a query using linq to NHibernate, for EnterAndExitArchive entity. This entity has a association by Archive entity. public EnterAndExitArchive GetLastEnterAndExitArchive(long archiveId) { var q =…
Ehsan
  • 3,431
  • 8
  • 50
  • 70
5
votes
1 answer

Linq to NHibernate query comparing enum mapped as integer succeeds, but fails as equivalent criteria query

I'm querying for ProductRisk, which contains a Status property, where Status is an enum. Here's the mapping for ProductRisk: public class ProductRiskMap : ClassMap { public ProductRiskMap() { …
Vish
  • 453
  • 6
  • 18
5
votes
1 answer

Is Linq to NHibernate in the 2.1 Alpha release?

So the nHibernate 2.1 Alpha came out a few days ago, but the announcement on sourceforge doesn't mention the additional features. In particular, it doesn't mention whether LINQ is included. I know that I've read that LINQ would be part of 2.1, but…
John
  • 3,332
  • 5
  • 33
  • 55
5
votes
2 answers

NHibernate / MySQL string concatenation

I have a nhibernate linq query that looks like this: from b in session.Query() where b.Uri.Equals(uri) || b.Uri.Equals("www." + uri) || string.Concat("www.", b.Uri).Equals(uri) select b This blows up, saying Concat isn't support,…
Andrew Boyd
  • 171
  • 1
  • 12
5
votes
1 answer

NHibernate CreateAlias - Joins on arbitrary columns

This question seems to come up a bit and I've yet to see a good answer. I have two classes with no foreign key and no real relationship other than a common field, in this case "Title". This is loosely based on an example I'd recently pulled from a…
5
votes
1 answer

NHibernate using wrong table alias

I am trying to filter a collection based on a foreign key. I have two classes which are mapped with public class GroupPriceOverrideMap:ClassMap { public GroupPriceOverrideMap() { CompositeId() …
stimms
  • 42,945
  • 30
  • 96
  • 149
5
votes
2 answers

Nhibernate 3 Linq - inner joins

I'm testing out nhibernate 3 CR, but fails to create the following SQL using Linq: select * from Users as {user} inner join Test as test on test.UserId = user.Id inner join Release …
bondehagen
  • 890
  • 1
  • 8
  • 11
5
votes
2 answers

How do I express this LINQ query using the NHibernate ICriteria API?

My current project is using NHibernate 3.0b1 and the NHibernate.Linq.Query() API. I'm pretty fluent in LINQ, but I have absolutely no experience with HQL or the ICriteria API. One of my queries isn't supported by the IQueryable API, so I presume…
Brant Bobby
  • 14,956
  • 14
  • 78
  • 115
5
votes
2 answers

How do you return certain properties from a linq query, rather than complete objects?

I've just downloaded the Linq provider for NHibernate and am just a little excited. But I don't know Linq syntax that well. I can return whole objects from a query like this: var query = from foo in session.Linq() …
David
  • 15,750
  • 22
  • 90
  • 150
5
votes
1 answer

NHibernate OrderByDescending throwing exception `A recognition error occurred`

When using: .OrderByDescending(review => review.Country.Id == reviewCountryID) the SQL query is generated correctly and no error is thrown. When using: .OrderByDescending(review => review.User != null && review.User.Country != null && …
Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169