Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8680597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:17:29+00:00 2026-06-12T21:17:29+00:00

I have a class structure like below. ObservableCollection<Group> deviceCollection = new ObservableCollection<Group>(); public class

  • 0

I have a class structure like below.

ObservableCollection<Group> deviceCollection = new ObservableCollection<Group>();
public class Group 
{ 
    public string Name { get; set; }       
    public List<TargetSelectionStructure> TargetCollection { get; set; }
}
public class TargetSelectionStructure
{
    public string ItemId { get; set; }
    public string Name { get; set; }
    public bool IsGroup { get; set; }
}

From the observable collection object deviceCollection. I need to get the collection which matches with IsGroup property as false. So I have written like

var currentStruct = deviceCollection.Where(d => d.TargetCollection.Any(t => t.IsGroup == false));

Now the currentStruct should contain the collection basically List<TargetSelectionStructure>. I am unable to cast the currentStruct to the type of List<TargetSelectionStructure>.
How can I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:17:30+00:00Added an answer on June 12, 2026 at 9:17 pm

    You can’t cast it, because currentStruct is an IEnumerable<Group>.

    I think you query needs to look like this:

    var currentStruct = deviceCollection.SelectMany(x => x.TargetCollection)
                                        .Where(x => !x.IsGroup).ToList();
    

    This returns all TargetSelectionStructure instances from all Groups that have IsGroup == false.

    Your question is not entirely clear. It is possible to interpret your question in a second way: You want to have all TargetSelectionStructure instances from a Group if at least one of them has IsGroup == false.
    To achieve this, you would use this query:

    var currentStruct = deviceCollection.Where(x => x.TargetCollection
                                                     .Any(y => !y.IsGroup))
                                        .SelectMany(x => x.TargetCollection)
                                        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a structure like: class SomeObject Public Name as String Public Created
I have a structure like below: public class BaseClass { public string SendError(string Message){
I have a object structure like this: public class Entity { IList<Relationship> Relationships{get;set;} }
I have the following class structure: class Organization { string Name; List<User> users; List<Organization>
We have a structure like below: template<size_t size> class Container{ public: char characters[size]; };
i have a t_my_class table structure like below (MySql table) id class group age
I have the following structure. public class ToolSettings { public string Extension { get;
I have a class structure like abstract class Animal { public Animal(){ //init stuff..
I have a class structure like: abstract class A { String a; } class
I have a list of objects (Debtors) in this structure public class DebtorDto {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.