locked
highlight duplicate records RRS feed

  • Question

  • User-2060576634 posted

    hi everybody.. i have a list of phone numbers generated from a query like below:

    @{
    
    var query=db.query(somequery);
    
    foreach(var row in query)
    {
       <li>@row.Phone</li>
    }
    
    
    
    
    }

    how can i highlight duplicate phone numbers?

    Monday, June 1, 2015 2:46 AM

Answers

  • User1577371250 posted

    Hi,

    Check this

    var query = db.query(somequery);
    
    var list = query.GroupBy(c=> c.Phone).Select(c=> c.Key).ToList();
    
    foreach(var row in query)
    {
        if(list.Contains(row.Phone))
        {
            <li style="font-size:20px;">@row.Phone</li>
        }
        else
        {
            <li>@row.Phone</li>
        }
      }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2015 6:03 AM

All replies

  • User1577371250 posted

    Hi,

    try this

    @{
    
    var query = db.query(somequery);
    
    var list = query.GroupBy(c=> c.Phone);
    
    foreach(var row in query)
    {
        if(list.Contains(row.Phone))
        {
            <li style="font-size:20px;">@row.Phone</li>
        }
        else
        {
            <li>@row.Phone</li>
        }
      }
    }

    Monday, June 1, 2015 3:52 AM
  • User-2060576634 posted

    try this


    i'm getting this error:

    CS1973: 'System.Collections.Generic.IEnumerable<System.Linq.IGrouping<dynamic,dynamic>>' has no applicable method named 'Contains' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

    Monday, June 1, 2015 5:10 AM
  • User1577371250 posted

    Hi,

    Check this

    var query = db.query(somequery);
    
    var list = query.GroupBy(c=> c.Phone).Select(c=> c.Key).ToList();
    
    foreach(var row in query)
    {
        if(list.Contains(row.Phone))
        {
            <li style="font-size:20px;">@row.Phone</li>
        }
        else
        {
            <li>@row.Phone</li>
        }
      }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 1, 2015 6:03 AM