I have Asp.net profile property Profile.Location, Gender etc
i need to get list of all users whose Location belongs to "London" and Gender = male
how do i perform a search on Asp.net Profile using LINQ
I have Asp.net profile property Profile.Location, Gender etc
i need to get list of all users whose Location belongs to "London" and Gender = male
how do i perform a search on Asp.net Profile using LINQ
Actually, you can do it. But you need to put a couple of things in place first:
Here's a CLR function that I wrote that parses the PropertyNames and PropertyValuesString column values from the aspnet_Profile table. It returns a table with a Property column and a Value column.
Deploy that function and then create a view for your user's profile data. Here's an example:
Voila, you can query the view with SQL or the ORM of your choice. I wrote this one in Linqpad:
consider using something like this:
I should probably mention that we've created an edmx file for our membership database. That said, I'd consider moving all of that interesting information into it's own tables in your application database when you get a chance.
No, you can't do this through the default ASP.NET profile provider (which saves profile data in a single string field in the database) though you still can do this after separating profile data in another database table (which is a common approach as well to store your profile data in another table and wire it with the default users table via the User GUID key), then you can use LINQ to query your users profiles data.