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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:02:27+00:00 2026-06-07T17:02:27+00:00

I implemented a search engine in my website that uses Linq-To-Sql . The output

  • 0

I implemented a search engine in my website that uses Linq-To-Sql. The output of the engine is a list of Result.
To increase security and performance, I’ve added a CachedResult table to my database. It had these columns:
ID, Date, Output
Where Output is a string which represents a list of integers which are the IDs for another table.
Using the Where method, I was able to extract those elements from the database. The problem is that their order is based on their order in the table, not the order of the integers in my string.
Therefore, I’ve added the OrderBy method this way:
db.Uploads.Where(upl => W.Contains(upl.UploadID)).OrderBy(pp => W.IndexOf(pp.UploadID));
W here is a list of integers (extracted from the database).
The probelm is that it throws an exception saying that the Linq-To-Sql translator cannot translate the List.IndexOf method to the appropriate SQL query.

I would like to know if I’m doing this right and there is a solution, or maybe I’m totally wrong and I must seek another way? (i.e making another table that has a relationship with CachedResults)

  • 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-06-07T17:02:28+00:00Added an answer on June 7, 2026 at 5:02 pm

    You can realise the result as a list before sorting, so that it uses Linq-To-Objects instead of Linq-To-Sql for the sorting:

    db.Uploads
      .Where(upl => W.Contains(upl.UploadID))
      .ToList()
      .OrderBy(pp => W.IndexOf(pp.UploadID));
    

    However, that’s not very efficient. As the IndexOf method is an O(n) operation, the sorting will be an O(n2) operation.

    Antother solution is to add another table CachedResultItems for the integers for each cached result, containing fields like:

    ID       int
    Ouptut   int
    Position int
    

    Instead of storing a string like 5,7,12,26,81 in the CachedResult table, you would have these records in the CachedResultItems table (for the ID 42 in the CachedResult table):

    ID   Output  Position
    ---- ------- ---------
    42   5       1
    42   7       2
    42   12      3
    42   26      4
    42   81      5
    

    Then you can join the two tables, and sort the result on Position.

    This would also be faster than first getting one result, splitting the string to a list, and use that list in a query, as it’s a single query, and it can use indexes more efficiently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a search engine and I have some implemented algorithms that
I'm trying to implement Search Engine. I have web application that displays list of
I have implemented a search engine in C for my html website. My entire
In my website I have implemented search feature using full-text search. It works fine
I have implemented a UISearchDisplayController that allows users to search a table. Currently the
I implement search engine dedection using the element in conjunction with the mammoth list
In our desktop application, we have implemented a simple search engine using an inverted
I have a website A with a database and a search engine of some
How can we implement Mechanize for bing and yahoo search engine? For google implementation
I have implemented solr search for my rails application. I have indexed the fields

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.