none
how to make all arguments/parameters all one case in this Linq Query? RRS feed

  • Question

  • I am querying a list of Emails in my In Box against my Contacts list.  I just want to know how to make all the args/params the same case:

    var emailsToAdd = (from email in emails
                                   let existingContacts = from contact in contactList
                                                          select contact.Email1Address
                                   where !existingContacts.Contains(email.SenderEmailAddress)
                                   orderby email.SenderName
                                   select new { email.SenderName, email.SenderEmailAddress }).Distinct();
    Thanks

    Rich P



    • Edited by Rich P123 Wednesday, October 16, 2013 8:36 PM ...
    Wednesday, October 16, 2013 8:32 PM

Answers

  • Hi Rich;

    This should work to compare the strings in the same case.

    var emailsToAdd = (from email in emails
                                   let existingContacts = from contact in contactList
                                                          select contact.Email1Address.ToUpper()
                                   where !existingContacts.Contains(email.SenderEmailAddress.ToUpper())
                                   orderby email.SenderName
                                   select new { email.SenderName, email.SenderEmailAddress }).Distinct();

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by Rich P123 Thursday, October 17, 2013 3:08 PM
    Thursday, October 17, 2013 2:25 AM