OnLoaded event or manually loading additional data
I have an object Group
that contains a string array of user names.
public partial class Group: IDomainObject, IEquatable<Group>
{
partial void OnLoaded()
{
}
[DataMember]
public string[] UserNames{ get; set; }
I then have a method which gets all my groups using Linq 2 Sql, and then manually loads this array of user names.
public List<Group> GetAllGroups()
{
try
{
LoadOptions = GetMyLoadOptions();
List<Group> groups = FindAll<Group>();
foreach (Group g in groups)
g.UserNames= g.MemberUsersMap.Select(map => map.User.Name).ToArray();
return groups;
}
}
I'm curious on the benefits/drawbacks of performing this task (loading user names) here after my query 开发者_开发问答vs using the OnLoaded method of my Group object. I guess I'm mainly thinking performance concerns when I have many groups to return.
精彩评论