Sorting and user defined properties

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 27-Feb-2007 21:09:19   

Hi,

I have added a few properties to a XXXXEntity. Now I want to fill a datasource with occurrences of XXXXEntity and sort on one of these extra properties.

I achieved this by using code like:

sorter.Add(new EntityProperty("Xyz" | SortOperator.Ascending);

where Xyz is one of the extra properties. This works fine as long as one specifies SortingMode = ClientSide for the datasource.

What needs to be done if I want this sort to run at the ServerSide?

Best regards,

Jan

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 27-Feb-2007 22:53:56   
IEntity2 sortField = new EntityField("name of field", [my expression]);
ISortExpression sorter = new SortExpression(sortField | SortOperator.Ascending);

where [my expression] mimics the funtionality of the property you defined.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 27-Feb-2007 23:53:06   

I have the impression that the example you provided will only work when the SortingMode for the datasource is set to ClientSide. There is some difference between your code and mine, but I think it has the same effect.

When I set the SortingMode to ServerSide I get an error.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 28-Feb-2007 02:17:33   

When you say server side you are talking about using the sort in the database server. I may misunderstand, but these user defined properties don't exist in the db usually. So these properties are most likely only sortable on the client-side. The client side being the LLBLGen layer.

If I'm way off just post the error you get and we'll be more help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 28-Feb-2007 10:30:08   

sorting on custom properties you added yourself is always client-side as the entity doesn't have these fields in the db.

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 28-Feb-2007 21:55:14   

Perhaps I could have done this differently.

I have 2 entities A and B with A : B = 1 : n.

I have a gridview in which I want to showB and two fields from A. I achieved this by adding two properties to B presenting the field from A. Doing that enabled me to use LLBLGenProDataSource and show the fields in the view. For the order in which the entities are displayed I also added the new properties to the sorter. It would only work with clientside sort on.

In the pre-LLBLGenPro days I would create a StoredProcedure that returned all the fields necesary in the order required.

Is the way I have build it, the way I should? Or is there a better alternative (whitout using extra views or stored procs).

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Mar-2007 02:55:17   

Did you add the related fields using the designer and the related fields on related entities functionality?

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 01-Mar-2007 22:27:44   

Yes.

The problem is that that does not seem to genrate entries in XXXXFields. And that are the things you need to specify e SortExpression.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 02-Mar-2007 01:58:39   

It won't be in XXXXFields since that represents fields in that table. It would be in YYYYFields and you could use a relationship along with the sort for that to work correctly on the server side.