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

Custom binding and filtering on DTO

2 Answers 127 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.
Pieter
Top achievements
Rank 1
Pieter asked on 18 Aug 2011, 09:42 AM
I want to use custom binding on a grid which displays a DTO. I'm using nHibernate to load information from the database. However, I'm getting the following error message:
System.Exception: Could not determine member from IIF((item != null), item.Status, Onbekend)

The field 'Status' comes from the DTO, but is named differently in the original entity. However, filtering as in the demo doesn't work when I do this:
if (command.FilterDescriptors.Any())
 {
    query = query.Where(ExpressionBuilder.Expression<MyDto>(command.FilterDescriptors));
}

The original queryover is structured as follows:
var query = Session.QueryOver<OriginalEntity>(() => entityAlias)
                .SelectList(.....)
                .TransformUsing(Transformers.AliasToBean<MyDto>());

How do I instruct the ExpressionBuilder to work on the DTO instead of on the original entity?

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 19 Aug 2011, 12:41 PM
Hello Pieter,

Is moving the projection into the DTO at the end after the filtering, sorting etc. makes any difference?

Best wishes,
Rosen
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

0
Pieter
Top achievements
Rank 1
answered on 19 Aug 2011, 12:47 PM
Rosen,

I don't really want to do that, as the entity has a lot of child collections which would be retrieved causing the performance of the query to degrade. The projection makes sure only the relevant portions of the entity are retrieved from the database.
I have modified the code to check the MemberName in the FilterDescriptor and based on that name I add a Where-clause to the query. It's a bit more work but it gets the job done.
Tags
Grid
Asked by
Pieter
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Pieter
Top achievements
Rank 1
Share this question
or