开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜