I have a Docs model with a guid column, author_id, which should reference MemberhipUser.
I use the standard MemberhipProvider (I just changed the db name), and of course I don't have a model for MembershipUsers.
I can easily define some methods in Docs classes to get membership for Doc and all Docs for MemberhipUser, but some things are complicated (enumerating users, displaying the number of documents of each user); Also, I feel like I'm using MVC in an odd way: it seems to me that it would be easier if I had the MembershipUsers model ...
How can I implement this relationship? Should I implement a model for MembershipUsers?
thanks
update: I understand that I was not entirely clear.
Let's say I want to list all of my users and their documents. One way to do this:
ViewModel model = new ViewModel()
{
Users = from MembershipUser user in Membership.GetAllUsers(page, pagesize, out totalusers)
select new UserWithDocs
{
User = user,
Docs = context.Docs.Where(c => c.author_id == (Guid) user.ProviderUserKey)
},
UsersCount = totalusers
};
This works, but generates one separate request for each user.
I could get an array of user requests and then query for Docs where author_id IN list_of_guids, but then I have to manually link each document with its author.
What is the best solution?
source
share