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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:00:43+00:00 2026-05-13T16:00:43+00:00

I am using LINQ within a webservice that creates an autocomplete function on a

  • 0

I am using LINQ within a webservice that creates an autocomplete function on a text box. I’ve got it to work but unfortunately the results are not being populated in the order I expect, for example, if I was search for drinks beginning with “carl” I’d expected “carling” first and then “carlsberg” but this is not the case.

The webservice being used is:

public string[] GetProdDesSearch(string prefixText, int count)
    {

        try
        {
            ReportingService.ProductsDataContext dbac = new  ReportingService.FinalProductsDataContext();

            return dbac.FINALPRODUCTSNEWDEMOs
                .Where(r => r.MemberId == HttpContext.Current.Session["MemberKey"].ToString() && r.IDDesc.Contains(prefixText))
                .OrderBy(r => r.UnitDescription)
                .Select(r => r.IDDesc)
                .Distinct()
                .Take(count)
                .ToArray();

        }

        catch (Exception)
        {
            return null;
        }
    }

    }

The .net detail is as follows:

 <asp:TextBox ID="tbxProdAC" runat="server"  
    style="z-index: 1; left: 200px; top: 460px; position: absolute; height: 20px; width: 345px;" 
    CssClass="completionList2" AutoPostBack="True" 
     ontextchanged="tbxProdAC_TextChanged"></asp:TextBox>   


<cc1:AutoCompleteExtender ID="tbxProdAC_AutoCompleteExtender" runat="server" 
    DelimiterCharacters="" Enabled="True" 
    ServicePath="~/Reporting/GetProd.asmx" 
    ServiceMethod="GetProdDesSearch" 
    TargetControlID="tbxProdAC" 
    CompletionInterval="50" CompletionSetCount="50" 
    MinimumPrefixLength="3"
    onclientpopulating="ShowImage"
    onclientpopulated="HideImage" 
    CompletionListCssClass="completionList2">
</cc1:AutoCompleteExtender>

.completionList2 {font-family: Trebuchet MS;font-size:11px; border:solid 1px #444444;margin:0px;padding:2px;height: 395px;
            overflow:auto; background-color:White;
          z-index: 1;
          left: 200px;
          top: 310px;
          position: absolute;
          width: 1496px;

      }

If someone can point out the error in my ways, I would be extremely grateful.

  • 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-13T16:00:43+00:00Added an answer on May 13, 2026 at 4:00 pm

    I’ve found the answer.

    The distinct should be placed BEFORE the orderby in my LINQ query within the webservice:

    return dbac.FINALPRODUCTSNEWDEMOs
                    .Where(r => r.MemberId == HttpContext.Current.Session["MemberKey"].ToString() && r.IDDesc.Contains(prefixText))
                    .Distinct()
                    .OrderBy(r => r.IDDesc)
                    .Select(r => r.IDDesc)
                    .Take(count)
                    .ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Linq to SQL within an ASP.NET MVC application. The model consists of
I am using c#.net and LINQ Within my LINQ model I have three database
I am using LINQ and am having a hard time understanding how I can
This question is tied in with this other question that I asked I have
I have a small business that sells website solutions to clients. The websites serve
I have ADAM set-up & I've written web-services to complete admin tasks like adding
I have an XML file similar to the following: <novel> <paragraphs> <paragraph> <choice>This is
I am trying to learn Asp.net Mvc so I am trying out this Tutorial.
i have an array like below int[] array = new array[n];// n may be

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.