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

Best way to delete all rows in a table using NHibernate?

To keep my integration tests independent I remove all old data and insert new test data before each test. Is there a better way of doing this than simply querying for all entities and deleting them one by one? I have considered writing a stored proc…
Erik Öjebo
  • 10,821
  • 4
  • 54
  • 75
37
votes
5 answers

Convert anonymous type to new C# 7 tuple type

The new version of C# is there, with the useful new feature Tuple Types: public IQueryable Query(); public (int id, string name) GetSomeInfo() { var obj = Query() .Select(o => new { id = o.Id, …
36
votes
2 answers

Eagerly fetch multiple collection properties (using QueryOver/Linq)?

I found 2 similar questions: Multiple Fetches in linq to nhibernate Is this the right way of using ThenFetch() to load multiple collections? According to this page: Be careful not to eagerly fetch multiple collection properties at the same…
user593358
32
votes
5 answers

NHibernate 3.0: No FirstOrDefault() with QueryOver?

I am playing with FluentNHibernate and NH 3.0, using the LINQ provider and the new QueryOver syntax. Now with QueryOver I want to get an item (called result) with a timestamp value as close as possible to a given value, but not greater: Result…
Marcel
  • 15,039
  • 20
  • 92
  • 150
30
votes
2 answers

Problem with linq query

I'm trying to use linq to NHibernate (with Fluent NHibernate) but I have problems with linq query. Everytime I try to execute it I get this message : "Method 'get_IsReadOnlyInitialized' in type 'NHibernate.Linq.Util.DetachedCriteriaAdapter' …
Athina
  • 533
  • 5
  • 20
28
votes
5 answers

How can I run NHibenate queries asynchronously?

One way to increase scalability of the server application is to run IO-bound operation (reading files, sockets, web requests, database requests etc) asynchronously. This does not mean run them in the ThreadPool which will just block threads while…
andrey.tsykunov
  • 2,896
  • 2
  • 32
  • 21
25
votes
3 answers

Nhibernate Linq In Clause

Is it possible to get Nhibernate linq to generate a query with an "In" clause? e.g. - Where AnID in (x,y,z)?
CocoB
  • 345
  • 3
  • 5
24
votes
1 answer

NHibernate - Where ISession.Query() is located

When I try to compile the following code using System; using System.Collections.Generic; using System.Reflection; using System.Linq; using NHibernate; namespace NewNHTest { class A { } class Program { static void…
StuffHappens
  • 6,457
  • 13
  • 70
  • 95
23
votes
3 answers

NHibernate with or without Repository

There are several similar questions on this matter, by I still haven't found enough reasons to decide which way to go. The real question is, is it reasonable to abstract the NHibernate using a Repository pattern, or not? It seems that the only…
vgru
  • 49,838
  • 16
  • 120
  • 201
23
votes
4 answers

NHibernate.Linq LIKE

How can I produce this query using NHibernate.Linq? WHERE this_.Name LIKE @p0; @p0 = 'test' // Notice NO % wild card Note, this is not Linq To Sql or Entity Framework. This is NHibernate. Edit: Here is the desired query using…
mxmissile
  • 11,464
  • 3
  • 53
  • 79
23
votes
3 answers

LINQ Fluent NHIBERNATE .Contains() does not work in QueryOver<> but works in Query<>

Using FNH, i am trying to retrieve categories, using the following: _session.QueryOver() .Where(c => tourCreateRequest.Categories.Contains(c.CategoryId)) …
jaxxbo
  • 7,314
  • 4
  • 35
  • 48
22
votes
7 answers

How can I use Nhibernate to retrieve data when the "WHERE IN()" have thousands of values? (too many parameters in the sql)

The problem: Nhibernate parses each value in the "WHERE IN()" sql as parameters and MS SQL server doesn't support enough parameters (over 2000). I am using Nhibernate with Linq to retrive my data from the SQL server and I need to load alot of…
Kenneth_hj
  • 485
  • 1
  • 4
  • 11
18
votes
4 answers

Getting count with NHibernate + Linq + Future

I want to do paging with NHibernate when writing a Linq query. It's easy to do something like this: return session.Query() .OrderByDescending(payment => payment.Created) .Skip((page - 1)*pageSize) .Take(pageSize) …
Allrameest
  • 4,364
  • 2
  • 34
  • 50
17
votes
2 answers

Difference between deferred execution and Lazy evaluation in C#

Could you please let me know what is the exact deference between deferred execution and Lazy evaluation in C#?These two are used synonymously.Could some one please explain the difference with an example??
babu m
  • 179
  • 1
  • 1
  • 3
15
votes
3 answers

LINQ to Nhibernate duplicates joins

I have a query like this var orderedQueryable = this.participationRequests .Fetch(x => x.CommunityEvent) .Fetch(x => x.CommunityMember) .ThenFetch(x => x.User) .Where(x =>…
Sly
  • 15,046
  • 12
  • 60
  • 89
1
2 3
41 42