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
7
votes
3 answers

Linq to NHibernate: sum of sums

Having NHibernate entities: Company, Invoice and InvoiceLine which has a decimal property Price. A Company has a collection of type Invoice, and an Invoice has a collection of type InvoiceLine. How can I obtain the sum of all prices that belong to…
Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169
6
votes
1 answer

Conditional operator in Linq Expression causes NHibernate exception

I'm trying to implement search functionality in an ASP.NET MVC 2 application. I create an expression based on criteria entered by the user: public ViewResult FindCustomer( string forename, string familyname, DateTime? dob) { …
Babakoto
  • 63
  • 1
  • 8
6
votes
2 answers

Grouping in condition is being dropped

LINQ to NHibernate removes parenthesis in where clause: session.Query().Where(x => (x.MyProp1 < end && x.MyProp1 > start) || (x.MyProp2 < end && x.MyProp2 > start)); This results in the following query…
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
6
votes
1 answer

Multiple fetch in ThenFetch

I've an associated entity with and that entity has two that I want to fetch at once. I can achieve this by this query: var tshead = session.Query() …
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
6
votes
4 answers

How do I combine two Expressions?

I am trying to build up an expression that will be applied to an IQueryable collection. I can build an expression like this: [TestClass] public class ExpressionTests { private IQueryable entities; private class MyEntity { …
Jonathan Moffatt
  • 13,309
  • 8
  • 51
  • 49
6
votes
1 answer

Nhibernate could not resolve property exception when using QueryOver, works on QueryAll

I have the following problem Basically I have the 2 snippets below: var contactAssociation = session.QueryOver(() => contactAssociationAlias) .Where(() => contactAssociationAlias.Contact.ID ==…
Para
  • 2,022
  • 5
  • 34
  • 73
6
votes
3 answers

Extending LINQ to Nhibernate provider, in combination with Dynamic LINQ problem

I'm using NHibernate 3.1.0 and I'm trying to extend the LINQ provider by using BaseHqlGeneratorForMethod and extending the DefaultLinqToHqlGeneratorsRegistry as explained in Fabio's post. For example, to support ToString() I've created a…
murki
  • 879
  • 12
  • 21
6
votes
3 answers

Linq to NHibernate multiple OrderBy calls

I'm having trouble ordering by more than one field in my Linq to NHibernate query. Does anyone either know what might be wrong or if there is a work around? Code: IQueryable items = _agendaRepository.GetAgendaItems(location) …
Rob
  • 1,983
  • 2
  • 20
  • 29
6
votes
1 answer

LINQ to NHibernate and let keyword

Is this possible to use let keyword with nhibernate linq? I wrote var posts = from post in postsRepository.GetPosts(name) let commentsCount = (from c in NHUnitOfWork.CurrentSession.Linq() …
lkurylo
  • 1,621
  • 33
  • 59
6
votes
3 answers

How can I get distinct values using Linq to NHibernate?

I've been trying to get distinct values using Linq to NHibernate and I'm failing miserably. I've tried: var query = from requesters in _session.Linq() orderby requesters.Requestor ascending select requesters; return…
6
votes
2 answers

A different object with same identifier was already associated with the session error

Scenario: I have a customer object with lazy loading enabled. I use that throughout the program to call a list of customer for a listbox. It has relationships to the Division_Customer_Rel, Division_Email_Rel and Email_Address objects. All off the…
Gage
  • 7,365
  • 9
  • 47
  • 77
6
votes
1 answer

NHibernate Linq - Duplicate Records

I am having a problem with duplicate blog post coming back when i run the linq statement below. The issue that a blog post can have the same tag more then once and that's causing the problem. I know when you use criteria you can do the…
user291885
6
votes
3 answers

"No persister for" error with NHibernate, NHibernate.Linq and Fluent Mapping

I´m using Nhibernate 2.1.2.4000 GA with Nhibernate.Linq 1.0 and latest version of FluentNhibernate downloaded from master on github. Im doing some tests and whenever I try to delete a entity retrieved by a linq query i´m getting this error: No…
tucaz
  • 6,524
  • 6
  • 37
  • 60
6
votes
1 answer

Trouble formulating inner joins using NHibernate Linq query

Using NHibernate 3.3.1.400, I'm having problems expressing what is a simple SQL statment using NHibernate's Linq provider. My domain model looks like this: public class Site { public virtual Guid Id {get; set;} public virtual string Name {get;…
David Montgomery
  • 1,618
  • 15
  • 28
6
votes
2 answers

Linq to NHibernate: Distinct

I am trying to get the following SQL output using Linq-to-NHibernate: SELECT DISTINCT Name, at.Year FROM MyTable mt INNER JOIN AnotherTable at ON at.Id = mt.AnotherTableId The Name and Year properties are going to be wrapped up in a new class, so…
cbp
  • 25,252
  • 29
  • 125
  • 205