c# - LINQ Query for a Nested Class -
as newbie c# , linq, i'm rather confused implementation of particular query i'm attempting. have array of 1 particular class called session. 1 of properties of class array of activeconnection, class. each activeconnection contains enumeration processtype.
here's goal: need determine session objects said array contain activeconnection proccesstype.guest. after plenty of fiddling, i've got code below (which doesn't compile anymore).
// creating array session[] var sessions = getsessions(); var busysessions = sessions sessions.activeconnections.processtype != processtype.guest select sessions; // other stuff array of busy sessions clearly, don't understand how implement linq query. help appreciated.
you need nested query (since activeconnections collection):
var result = sessions.where(session => session.activeconnections.any(conn => conn.processtype == processtype.guest)); this homecoming sessions guest in activeconnections list (which said). code did, need:
var result = sessions.where(session => session.activeconnections.all(conn => conn.processtype != processtype.guest)); c# linq
No comments:
Post a Comment