我有这些课程:
public class ZoneMember
// a zone member is a member of a zone
// zonemembers have ports, WWPNs, aliases or all 3
{
private string _Alias = string.Empty;
public string MemberAlias {get{return _Alias;} set{_Alias = value; } }
private FCPort _Port = null;
public FCPort MemberPort { get { return _Port; } set { _Port = value; } }
private string _WWPN = string.Empty;
public string MemberWWPN { get { return _WWPN; } set { _WWPN = value; } }
private bool _IsLoggedIn;
public bool IsLoggedIn { get { return _IsLoggedIn; } set { _IsLoggedIn = value; } }
private string _FCID;
public string FCID {get{return _FCID;} set{ _FCID=value; } }
}
public class Zone
{
public List<ZoneMember> MembersList = new List<ZoneMember>();
private string _ZoneName;
public string zoneName{ get{return _ZoneName;} set{_ZoneName=value;} }
public Zone(string n) { zoneName=n; }
}
public class ZoneSet
{
private string _ZoneSetName;
private int _VSANNum;
public string ZoneSetName{get{ return _ZoneSetName;} set{_ZoneSetName=value;} }
public int VSANNum{ get{ return _VSANNum;} set{_VSANNum=value;} }
public bool isActive;
public List<Zone> ZoneList = new List<Zone>();
}
我想在 Zoneset 中找到所有具有区域成员的区域,该成员具有特定值的成员列表中的属性。
我知道这样的事情会起作用 - 在这种情况下,我正在搜索 WWPN 属性:
// assumes myZoneSet has already been instantiated ad has zones in it
// and inputWWPN in the select statement has the value we want
List<Zone> myZoneList = new List<Zone>();
foreach (Zone z in myZoneset)
{
var zm=null;
zm = from member in z.MembersList where member.MemberWWPN == inputWWPN select member;
// if we find a matching member, add this zone to the list
if (zm != null)
{ myZoneList.Add(z);
}
}
有没有办法使用 LINQ 来完成整个事情?我不确定数据库术语中的术语是什么。