Sorting problem

Posts   
 
    
ts_mjolner
User
Posts: 13
Joined: 28-Sep-2007
# Posted on: 02-Oct-2007 19:38:50   

Hey there!

I have a problem: On lists shown in my application I have added sorting when pressing any header of any column. A list which is shown does not only consist of data from one DB table, e.g. showing a list of orders, and each order is created by someone, that is just a foreign key to another table, but I still want to be able to sort on the username, so to handle this I'm using the following:

Pass an OrderCollection to the FetchEntityCollection() Pass a relation from OrderEntity to UserEntity to the FetchEntityCollection() Pass the SortExpression to the FetchEntityCollection()

However this has revealed some problems when data in the columns are allowed to be null in the DB. I have made it so that the IEntityRelation is only added to the bucket if I'm sorting on any of the foreign key fields, otherwise not. So when showing the list initially the list is showing fine, but then if I sort by username, I pass the relation on to the bucket and thereby all orders which has null as value in foreign key to user are not fetched because of the INNER JOIN which is generated by the relation object.

So basically my question is: How to handle relations when foreign keys are allowed to be null?

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 02-Oct-2007 20:08:21   

Hi, when adding the relation to your relation container (IEntityRelation) you must look for an overload in order to pass this parameter: JoinHint.Left.

this thread may help you: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=9822&HighLight=1

ts_mjolner
User
Posts: 13
Joined: 28-Sep-2007
# Posted on: 02-Oct-2007 20:12:47   

Ah thanks alot, that should solve the problem.