I want to encapsulate the following query into a method that returns a query result (i.e. members).
I then want to take another query that will query off of that returned result.
I learned that I cannot use var as a parameter type or result type within the method that I want to create. I really wanted to have this support to make my life simple.
Additional details:
MembersItemsControl.Items property has a private member ‘_ItemsSourceAsList’ that is of type ‘Users’ which is a class that inherits from an ObservableCollection.
Any suggestions?
The query code is below:
var members = (from member in MembersItemsControl.Items
where
(
// Match either male or female selection
(member as UserInformation).sex.Equals("Male") ==
SeekingMale.IsChecked.Value &&
(member as UserInformation).sex.Equals("Female") ==
SeekingFemale.IsChecked.Value
)
||
(
// Provide both male and female if both options are selected
SeekingMale.IsChecked.Value == true &&
SeekingFemale.IsChecked.Value == true
)
select member);
You can always pass LINQ collection as
IEnumerable<Member>.Where
Memberis type of items inMembersItemsControl.Items.