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 808057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:30:11+00:00 2026-05-15T00:30:11+00:00

I have two ways that I am doing a fuzzy search for a customer.

  • 0

I have two ways that I am doing a fuzzy search for a customer. One is by an abbreviated name and the other is by the customer’s full name. When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Distinct() method on this, I also still get duplicates. Do I need to implement some compare functionality in my customer object?
My code:

        Dim shortNameMatch As List(Of ICustomer) = CustomerLibrary.GetCustomersByShortName(term)
        Dim custNameMatch As List(Of ICustomer) = CustomerLibrary.GetCustomersByCustName(term)
        Dim allMatch = (From a In (From s In shortNameMatch Select s).Union(From c In custNameMatch Select c) Select a).Distinct()
  • 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-05-15T00:30:12+00:00Added an answer on May 15, 2026 at 12:30 am

    You need to create an equality comparer and use it in the Union or Distinct:

    Public Class MyComparer
        Implements IEqualityComparer(Of ICustomer)
    
        Public Overloads Function Equals(ByVal x As ICustomer, ByVal y As ICustomer) _
            As Boolean Implements _
            System.Collections.Generic.IEqualityComparer(Of ICustomer).Equals
            Return ((x.id = y.id) AndAlso (x.title = y.title))
        End Function
        Public Overloads Function GetHashCode(ByVal obj As ICustomer) _
            As Integer Implements _
            System.Collections.Generic.IEqualityComparer(Of ICustomer).GetHashCode
            Return Me.GetHashCode()
        End Function
    End Class
    

    Usage example:

    Dim allMatch = shortNameMatch.Union(custNameMatch).Distinct(New MyComparer())
    Dim allMatch = shortNameMatch.Union(custNameMatch, New MyComparer())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two DropDownListBoxes one is called ddlDay and the other is ddlMonth. As
I have two application that need to talk to each other. App1 needs to
I have two queries that produce the same output. One is using the Intersect
Basically you have two ways for doing this: for (int x = 0; x
I have two function that do the exact same thing in two different ways.
I have two ways of doing a similar thing and would like to know:
I have two rails apps that I am thinking about merging into one because
I am trying to introduce RoR to my company and I have two ways
I want to send the form data to server-side. I have two ways: Normal
I have found two ways to extract matches in Python: 1. def extract_matches(regexp, text):

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.