我需要制作简单的“linq”请求。它应该是“linq to objects”请求。
所以,我有List<G> glist
,我希望从这个列表中获取所有GW对象。我希望看到像model.Select<G>( ... ).Where( ... ) ...
public class G : IEntity, ICloneable
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<GW> GWs { get; set; }
public override string ToString()
{
return Name;
}
public object Clone()
{
return this.MemberwiseClone();
}
}
public class GW: IEntity, ICloneable
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual G G{ get; set; }
public override string ToString()
{
return Name;
}
public object Clone()
{
return this.MemberwiseClone();
}
}
答案 0 :(得分:0)
您可以获得如下所示的所有gw对象:
List<GW> ListOfGW=(from g in glist let lgw=g.GWs from gw in lgw select gw ).ToList();