0

In reference to this question of mine, C# Custom list duplicate values based on a property

I have two custom lists, let say,

Public class HouseColony
{
     public string Name { get; set; }
     public string Location { get; set; }
     public string NumberOfHouses { get; set; }
}

Public class House
{
     public string Name { get; set; }
     public string Location { get; set; }
     public string AreaCovered { get; set; }
}

Now I am getting all HouseColony from a external web service, then while getting each HouseColony I am trying to get all House in this specific colony.

What I am trying to do

I don't want houses that have same number of AreaCovered in any of HouseColony.

For example: if House Colony A has a houses with Area Covered = 1009 then another house colony has any house with Area Covered = 1009 then ignore it Add house with area just once, at the moment I am doing this,

Foreach(HouseColny...)
{
   List<Houses> houses = new ...
   List<Houses> houses =  GetAllHouses(HouseColonyName);
}

I made up this scenario and naming convetion

Edit

Can I do something that relate houses with House Colony list and then compare then at end ?

Community
  • 1
  • 1
Mathematics
  • 7,314
  • 25
  • 77
  • 152
  • so if list B is found to contain a duplicate value also found in A, then both should be removed? Or only in B? – Wim Ombelets Nov 05 '13 at 15:00
  • How do you know which house you want? You'll get best results if you can set a rule for this, rather than the first one you happen to process. – Joel Coehoorn Nov 05 '13 at 15:01
  • @WimOmbelets I just need 1 record, so only 1 :) , thanks – Mathematics Nov 05 '13 at 15:01
  • @JoelCoehoorn I just don't want duplicate records of houses with same AreaCovered, :) – Mathematics Nov 05 '13 at 15:02
  • might be that I totally don't get the scenario, but if you delete this info from all but one list, how will it still be meaningful? how will you check later on for e.g. overlapping areas – Wim Ombelets Nov 05 '13 at 15:08
  • Perhaps this post could be of use: http://stackoverflow.com/questions/489258/linq-distinct-on-a-particular-property – Vlad Nov 05 '13 at 15:38

0 Answers0