【发布时间】:2012-04-16 20:17:58
【问题描述】:
我正在维护一个使用 _clientList.Add(clientIDGuid, newsfeedClient); 登录的客户字典
NewsfeedClient 类:
public class NewsfeedClient
{
/// <summary>
/// Represents Newsfeed's own clientID
/// </summary>
public string ClientIDGuid { get; set; } // also adding the dictionary's ID
/// <summary>
/// Represents the logged in client's session ID
/// </summary>
public string SessionID { get; set; }
public string Nickname { get; set; }
public int ProfileID { get; set; }
public GeoLocation Location { get; set; }
public List<MyDB.Models.Buddy> BuddyList { get; set; }
[ScriptIgnore]
public DateTime LastResponseTime { get; set; }
public class GeoLocation
{
public float Latitude { get; set; }
public float Longitude { get; set; }
}
}
Buddy 对象包含一个 ProfileID 属性。
我想获取所有字典 clientID 的列表,其中匹配的 profileID 在该新客户端的 BuddyList 中。
我猜测 Intersect 方法会发挥作用,如 here 所示,但我不太确定如何在不创建至少一个 foreach 循环的情况下将其组合在一起。
-- 更新--
clientID 不是 == ProfileID 这些值是不同的。
【问题讨论】:
-
所以,澄清一下 - 您想查找单个 NewsFeedClient 的 BuddyList 中包含的所有 ProfileId 的所有 NewsFeedClient 对象吗?
标签: c# linq collections asp.net-4.0