开发者

OnLoaded event or manually loading additional data

开发者 https://www.devze.com 2023-02-17 01:48 出处:网络
I have an object Group that contains a string array of user names. public partial class Group: IDomainObject, IEquatable<Group>

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

精彩评论

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

关注公众号