Skip to main content
added 2 characters in body
Source Link
AlexZh
  • 637
  • 4
  • 9

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key]))
                                    ).Count() > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key]))
                                    ).Count > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key]))
                                    ).Count() > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}
added 97 characters in body
Source Link
AlexZh
  • 637
  • 4
  • 9

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key]))
                                    ).Count > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key])).Count > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key]))
                                    ).Count > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}
Source Link
AlexZh
  • 637
  • 4
  • 9

If your fields "Contact","Role","Prority" are text types then:

instead:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.ToString().Equals(duplicate.FieldValues.ToString()))
         {
             item.DeleteObject();
         }
     }
     duplicate = item;
}

use:

foreach(ListItem item in oitems.ToList())
{
    if (duplicate != null)
    {                 
         if (item.FieldValues.Where(entry => 
                                    !Convert.ToString(item.FieldValues[entry.Key]).Equals(Convert.ToString(duplicate.FieldValues[entry.Key])).Count > 0)
         {
             item.DeleteObject();
         }
         else
         {
             duplicate = item;
         }
     }
}