Last post Mar 26, 2011 02:49 AM by uid231232
Mar 23, 2011 08:09 AM|nevets2001uk2|LINK
I'm looking for some advice on a quite complicated question I have over a good design to use in a particular part of a web app I am building. The area I'm working on is the friends element. I can make this work but I want to design this well and use the
most efficient and sensible approach as this is about learning as well as the end product.
I have a Person table which holds the main profile data for users. I have a Friends table which then links people together as follows
I will therefore have a single entry for each friendship. I toyed with double entry so I could query just by Person1ID to find all friends but this seems clunky. I am making a user control which will access the data via a function in a shared FriendCode
class. This function queries using Linq to Entity as I have used Entity Framework 4 for the model. Using two queries I can get all of the IDs for the friends as integers, combine them into a List of Integers to return to the user control. Then I would have
to write a sub in the control which queries the person table for the friends names and icons.
This seems like a lot of db calls I thought it would be better if I could return the Friend data from the function in the first place. I was able to make a List of Friend and use this to return data from the friend table requring no db calls in the user
control but because I'm combining two queries (one of Person1ID and the 2nd on Person2ID) and also need the names this gets more complex.
My idea is to create a class call FriendInfo which accepts the Fullname, Icon and ID data for the results from the db so I can return this. I've never used classes like this and I'm not sure if this is sensible and if I can even generate multiple FriendInfo
instances and return them all at once from the function?
Or is it just as easy to return a list of IDs for the friends to the user control and look up the extra data after that, as I am currently?
Mar 26, 2011 02:49 AM|uid231232|LINK