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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:54:36+00:00 2026-06-04T22:54:36+00:00

I have a line of LINQ code that throws a System.NotSupportedException. return unconvertedUrls .Select(potentialQueryURL

  • 0

I have a line of LINQ code that throws a System.NotSupportedException.

        return unconvertedUrls
                   .Select(potentialQueryURL => ConvertPotentialQueryURLToSeed(potentialQueryURL))
                   .Where(id => id > 0)
                   .ToList();

The exception message is “Method ‘Int32 ConvertPotentialQueryURLToSeed(SeedsSQLConnector.PotentialQueryURL)’ has no supported translation to SQL”

However the simple conversion to a foreach loop runs with no problems.

        var result = new List<int>();
        foreach (var potentialQueryURL in unconvertedUrls)
        {
            var id = ConvertPotentialQueryURLToSeed(potentialQueryURL);
            if (id > 0)
            {
                result.Add(id);
            }
        }
        return result;

What’s going wrong and why?

========== EDIT ==========

Odd, a colleague suggested another fix that works too. It looks like the LINQ was passing ConvertPotentialQueryURLToSeed to the database! Anyway here’s the other fix, which is to add .ToList() to the previous statement:

        var unconvertedUrls = (from url in _DataContext.PotentialQueryURLs
                               where !convertedUrlIds.Contains(url.Id)
                               select url).ToList();
        return unconvertedUrls
                   .Select(potentialQueryURL => ConvertPotentialQueryURLToSeed(potentialQueryURL))
                   .Where(id => id > 0)
                   .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-06-04T22:54:38+00:00Added an answer on June 4, 2026 at 10:54 pm

    The reason is that LINQ to SQL doesn’t execute that code of the query but tries to convert it to an SQL statement. As it doesn’t know ConvertPotentialQueryURLToSeed this conversion failes.

    The foreach works because in that case the method ConvertPotentialQueryURLToSeed is not used in the part of the LINQ query that is being translated to SQL.

    The version with ToList works for the same reason: ToList fetches the data from the query so far from the database. From that point onward, you are working on normal C# objects aka LINQ to Objects.

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

Sidebar

Related Questions

I have some Linq code and it's working fine. It's a query that has
I have a piece of code that filters a list using LINQ, creates a
I have have following line that is working correctly: html: <td> + goalcard.Name +
I have a line plot of some event at a hospital that I have
I have the following class which is intended to return the subject line of
I have written code in C# that should transform an XML with the help
i have this line in c# : byte[] bytes = new byte[streamReader.BaseStream.Length]; That Length
I have the following LINQ code: var posts = (from p in db.Posts .Include(Site)
I have a strange problem when deleteting records using linq, my suspicion is that
I have a C# app I'm working on that loads it's code remotely, and

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.