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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:35:34+00:00 2026-05-23T09:35:34+00:00

I am trying to return a distinct list – but instead of projecting the

  • 0

I am trying to return a distinct list – but instead of projecting the Distinct() operator over all the returned fields I only want the Suburb to have the operator applied to it like so lga.Suburb.Distinct() but this does not work – how do I go about this?

Thanks!

Public Function GetLGAForRegion(ByVal region As Integer)

    Dim dc As New DataContextDataContext
    Dim query = (From lga In dc.tblLGA_Suburbs
    Join suburb In dc.tblSuburbs On lga.Suburb Equals suburb.SuburbName
    Join regions In dc.tblRegions On suburb.RegionID Equals regions.RegionID
    Where (regions.RegionID = region)
    Select lga.Suburb.Distinct(), suburb.SuburbID).ToList()
    Return query

End Function

Ok – this works 🙂 Thanks for your help!

 Dim query = (From lga In dc.tblLGA_Suburbs
        Join suburb In dc.tblSuburbs On lga.Suburb Equals suburb.SuburbName
        Join regions In dc.tblRegions On suburb.RegionID Equals regions.RegionID
        Where (regions.RegionID = region)
        Group By lga = lga.Suburb Into g = Group
        Order By lga Ascending
        Select g.First().lga.Suburb, g.First().suburb.SuburbID).ToList()
  • 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-23T09:35:35+00:00Added an answer on May 23, 2026 at 9:35 am

    You can use GroupBy like this

    GroupBy(r -> r.Suburb).Select(g => g.First())
    

    in query style

    Dim query = (From lga In dc.tblLGA_Suburbs
    Join suburb In dc.tblSuburbs On lga.Suburb Equals suburb.SuburbName
    Join regions In dc.tblRegions On suburb.RegionID Equals regions.RegionID
    Where (regions.RegionID = region)
    Group lga by lga.Suburb into suburbGroup
    Select suburbGroup.First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to return a custome object from a web service object returned only
I'm trying to get a distinct list of characters (case sensitive) across all strings
I want to select all distinct order_ids from my table, and order that list
I'd like to iterate over a list of distinct fields in a given document.
Im trying to return a SimpleQuery list that queries a single table and uses
I'm trying to return a random number from a method but apparently the implicit
Im trying to query a List but unable to get the result the way
I'm trying to write a HQL/Criteria/Native SQL query that will return all Employees that
I'm adding values to a c# generic list while trying to prevent duplicates, but
I'm trying to construct a query that gives me a list of distinct records

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.