1

We have a system that is based around Events that Users are invited to [UserInvite].

Currently, I have a page that lists all the Users invited to an Event; they can be sorted by various properties, such as Surname [ascending and descending]. All fine and dandy, but now I'm required to additionally sort by a UserInvite property: DateEdited [again asc/desc]. I've been using an extension method that takes in a string of the property name to sort by, but this won't work for another class's property.

Notes:

  1. UserInvite has a method to get by Event and User which always returns a single UserInvite [or null if no invite was found].
  2. The current EventID is held in the Master page so can be reached on the page that lists the Users

What is the best way to do this?

1 Answer 1

1

Is there a route from the Event to the UserInvite? If so, simply walk the relation. Actually, the simplest approach is to re-expose this date on the Event - i.e.

public DateTime InviteDate {get {return Invite.Date;}} // or similar

and order by InviteDate - but you can also use a string like "Invite.Date" and split it by dots - for example, here's something similar for IQueryable<T> - although it doesn't handle null at the moment.

Sign up to request clarification or add additional context in comments.

1 Comment

The only working solution I've come up with was to add the UserInvite property into the User class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.