This is a migrated thread and some comments may be shown as answers.

Binding using nhibernate

4 Answers 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mary
Top achievements
Rank 1
mary asked on 12 Jan 2010, 12:18 AM
If using NHibernate and the grid's default binding, and the Model is set to:

public
IEnumerable<T> Get()  
{  
   
return Session.CreateCriteria(typeof(T)).Future<T>();  
} 

will this give a similar result as a linq query which defers the full results, so only one page will be fetched at a time?

thanks!

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Jan 2010, 08:36 AM
Hi mary,

No, I don't think this will work the way you suggested. Our expression engine will try to pass an expression to a linq provider which you are not using (instead using the criteria API of NH). I may suggest you try Linq to NHibernate for making the queries. Unfortunately there are known issues with the Linq2Nhibernate provider - it still does not support all kinds of expressions. For example filtering in the Grid does not work. Until this is fixed we cannot properly support filtering unless we patch our expression engine to work with Nhibernate's linq provider. The good news is that the aforementioned provider is being updated to have better support for expressions.

As a workaround you can use custom binding as shown in this example. The interesting part is in the controller.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Psycho Nelo
Top achievements
Rank 1
answered on 20 Mar 2010, 05:01 PM
I've tried to use Linq2Nhibernate provider and it does support filter expressions, for example .Where( x => x.Id = 1)
0
Sam
Top achievements
Rank 1
answered on 14 Dec 2010, 12:34 AM
Are there any updates on this?
0
Atanas Korchev
Telerik team
answered on 14 Dec 2010, 11:01 AM
Hi Sam,

 Filtering seems to work now with NHibernate 3.0. However grouping doesn't work. Nhibernate cannot execute the grouping query which is generated by the grid:

var orders = MvcApplication.NorthwindSession.Query<Order>();
 
orders.OrderBy(i => i.ShippedDate)
      .Take(10)
      .GroupBy(i => i.ShippedDate)
      .ToList();

I created a code library entry  which shows the Telerik MVC Grid bound to NHibernate (using FluentNHibernate) and LINQ. Paging, filtering and sorting should work as expected.



Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
mary
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Psycho Nelo
Top achievements
Rank 1
Sam
Top achievements
Rank 1
Share this question
or