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

  • SEARCH
  • Home
  • 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 7799127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:12:27+00:00 2026-06-02T00:12:27+00:00

I got tree objects. A object EFacebook , very simple, with a property called

  • 0

I got tree objects.

A object EFacebook, very simple, with a property called id.

class EFacebook
{
   public string id { get; set; }
}

A EUser, more complex. The EUser gets a list of EProvider inside, and each EProvider gets a type. Like:

class EUser
{
    public string name { get; set; }
    public List<EProvider> EProviders { get; set; }
}

class EProvider
{
   public enum EnumType
   {
      facebook = 1,
      twitter = 2
   }
   public string id { get; set; }
   public EnumType type { get; set; }
}

And two lists: (the list of providers, inside users, is optional, nullable):

// list of facebooks
List<EFacebook> facebooks = new List<EFacebook>();

facebooks.Add(new EFacebook { id = "1" });
facebooks.Add(new EFacebook { id = "2" });
facebooks.Add(new EFacebook { id = "3" });

// list of users
List<EUser> users = new List<EUser>();
List<EProvider> ps1 = new List<EProvider>();

ps1.Add(new EProvider { id = "1", type = EProvider.EnumType.facebook });
ps1.Add(new EProvider { id = "2", type = EProvider.EnumType.twitter });

List<EProvider> ps2 = new List<EProvider>();
ps2.Add(new EProvider { id = "3", type = EProvider.EnumType.facebook });
ps2.Add(new EProvider { id = "4", type = EProvider.EnumType.twitter });

EUser u1 = new EUser { name = "somea", EProviders = ps1 };
EUser u2 = new EUser { name = "someb", EProviders = ps2 };
EUser u3 = new EUser { name = "somec" };

users.Add(u1);
users.Add(u2);
users.Add(u3);

Now, I need to obtain two children lists of facebooks based on the relation between facebook.id and user.eprovider(of enum facebook).id. It means, a list of EFacebook containing only the object facebook with id 2, because I don’t have a user with a provider of type facebook and id 2, and a list of EFacebook containing the objects facebook with id 1 and 3, because I do have users with a provider of type facebook and id 1 and id 3.

I tried a lot, but It’s not working:

/*var xaa = users.Select(z => z.EProviders.Where(x => x.ProviderType == 
    EProvider.EnumProviderType.Facebook).Select(x => x.Ip).Zip(z);*/

/*var a = users.Select(x => x.EProviders.Where(y => y.ProviderType == 
    EProvider.EnumProviderType.Facebook));*/


/*
var outra = facebooks.Where(x=>                 
var a = from i in users
    where i.EProviders != null && i.EProviders.Any(j => j.ProviderType == 
    EProvider.EnumProviderType.Facebook)
from j in i.EProviders
join k in facebooks on j.Ip equals k.id
select k;

var b = facebooks.Except(a);
*/

Any help will be appreciated.

  • 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-02T00:12:29+00:00Added an answer on June 2, 2026 at 12:12 am

    How about:

    // Create an enumerable of all IDs of Facebook providers from the users list
    var facebookIds = users
        // Exclude all users with a null EProviders list
        .Where(u => u.EProviders != null)
        // For each user, select all EProviders with type == facebook
        // and use SelectMany to flatten them into a single enumerable
        .SelectMany(u => u.EProviders.Where(p => p.type == EProvider.EnumType.facebook));
    
    // Use Join to find all facebooks whose IDs also exist in the facebookIds set constructed above
    var facebooksWithUsers = facebooks.Join(facebookIds, f => f.id, p => p.id, (f, p) => f);
    
    // Use Except to find the opposite subset
    var facebooksWithoutUsers = facebooks.Except(facebooksWithUsers);
    
    // Write the contents of the two sets to the console
    Console.WriteLine("facebooksWithUsers:");
    foreach (var fb in facebooksWithUsers)
    {
        Console.WriteLine(fb.id);
    }
    
    Console.WriteLine();
    Console.WriteLine("facebooksWithoutUsers:");
    foreach (var fb in facebooksWithoutUsers)
    {
        Console.WriteLine(fb.id);
    }
    

    This outputs:

    facebooksWithUsers:
    1
    3
    
    facebooksWithoutUsers:
    2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

got a PictureBox (called i_MC) and i draw a simple image (m_ImgMCN) on it
I've got a bit of a situation with similar objects - basically, every object
I've got a unidirectional tree of objects, in which each objects points to its
I've got a tree which is populated by Node objects. Each node has an
i don't get the full grasp on python iterators, i got an object with
Background I've got the following tree of objects: Name Project Users nil John nil
heres my test in java public class person { public String name; public int
I've got a tree view that can be anywhere from 1 level deep to
I've got hierarchal data in the database, stored in Modified Preorder Tree Traversal format.
I have a class called XMLtoXML.java and this is one of it's methods... import

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.