I am wondering if the aspnet_Users
table is always sorted (by UserName) even if I add new users which are alphabetically between two already existing users.
I've noticed that the method Membership.GetAllUsers()
always seems to return a sorted collection of MembershipUsers.
Also when I look into SQL Server Management Studio and run a simple SQL query without ORDERBY
clause...
SELECT [UserName]
FROM [MyDb].[dbo].[aspnet_Users]
...I get always a sorted result list.
I'm still very unfamiliar with SQL Server but I expected that when I add a new row to a table it is (physically) appended to the end of the table. And when I run a select statement without ORDERBY the rows will be selected in the order they were initially inserted into the database (so without any specific sort order).
I am wrong I guess. But how does it really work? Is it perhaps something special with the aspnet_Users table?
I am happy that the MemberShipUserCollection returned by GetAllUsers() is sorted but is it always guaranteed?
Thanks for info!
Update
I've just noticed that the database contains a stored procedure called aspnet_Membership_GetAllUsers
. This procedure actually contains an ORDER BY
clause by UserName
. So if this stored procedure is indeed always called when I use Membership.GetAllUsers()
in my code (at least if I am using the SqlMembershipProvider) it explains why the collection returned by Membership.GetAllUsers()
is sorted by UserName.
Remains the question: Is Membership.GetAllUsers()
actually based on this stored procedure?