ASP.NET MembershipUserCollection sort by IsApproved, Comment
Is开发者_开发知识库 it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying the Stored Procedure? Can Linq do this?
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();
There is also this option to make it LINQ friendly before ordering.
IEnumerable<MembershipUser> members = sys.Membership.FindUsersByEmail(email).Cast<MembershipUser>();
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.
精彩评论