Hello, Is it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying the Stored Procedure? Can Linq do this?
Thanks!
Hello, Is it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying the Stored Procedure? Can Linq do this?
Thanks!
I found another example that used the following code (I used a generic List instead of MembershipUserCollection):
users = users.OrderByDescending(x => x.IsApproved).OrderBy(x => x.Comment).ToList();
EDIT: DOH! Need ThenBy() instead of a second OrderBy():
users = users.OrderByDescending(x => x.IsApproved).ThenBy(x => x.Comment).ToList();
Not directly--the MembershipUsersCollection isn't linq friendly. You can, however, pretty easily make it Linq friendly as Mike C. points out--just new up a List<MembershipUser>
with your users.
There is also this option to make it LINQ friendly before ordering.
IEnumerable<MembershipUser> members = sys.Membership.FindUsersByEmail(email).Cast<MembershipUser>();