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

  • Home
  • SEARCH
  • 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 489413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:48:20+00:00 2026-05-13T01:48:20+00:00

I have a class with a title in it. I have a property that

  • 0

I have a class with a title in it. I have a property that returns that title adjusted a bit. If I do Linq to Sql queries off the adjusted title property I get the “not supported” exception. If I do the same thing the property does directly in the linq query it works. Any ideas on how I can make the property work in Linq to Sql?

Here is the property

public string SeoName
{
    get { return Name.ToLower().Replace(" ", "").Replace("&", "and"); }
}

Here is the query that doesn’t work (What I would like to be able to do).

var series = from s in videoRepo.GetShows()
             where s.Topic.SeoName.Equals(topicSeoName)
             select s;

Here is a query that does the same thing and works

var series = from s in videoRepo.GetShows()
            where s.Topic.Name.ToLower().Replace(" ", "")
            .Replace("&", "and").Equals(topicSeoName)
            select s;

How can I structure the top property to work with the first linq query?

MY FINAL ANSWER

Added an expression that evaluated what I was looking for

public static Expression<Func<Show, bool>> 
        TopicSeoNameEquals(string name)
    {
        return t => t.Topic.Name.ToLower().
            Replace(" ", "").Replace("&", "").Equals(name);
    }

Then, I just called it a bit differently in the linq query

var test = Show.TopicSeoNameEquals(topicSeoName);

var series = from s in videoRepo.GetShows().Where(test)
            select s;
  • 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-13T01:48:20+00:00Added an answer on May 13, 2026 at 1:48 am

    Basically you can’t. LINQ to SQL has no way to “look inside” the SeoName property and translate it to SQL. However, when you write what appears to be the same code inline in the LINQ to SQL query, the compiler builds it in a way that LINQ to SQL can “look inside.” It creates an expression tree — an abstract description of the sequence of operations in the query — rather than compiling the code down to MSIL.

    You can work around this by creating an Expression that does the same job as SeoName, but you still end up duplicating the SeoName code in order to get C# to compile one copy as a callable MSIL method and the other as an expression tree. (Though you can work around this by having your SeoName property work by compiling the expression tree at run time: this gets around the duplication at the expense of some performance and looking a bit strange.)

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

Sidebar

Related Questions

I have class method that returns a list of employees that I can iterate
I have class with internal property: internal virtual StateEnum EnrolmentState { get { ..getter
Let's say I have the following model: class Contest: title = models.CharField( max_length =
Actually my question is all in the title. Anyway: I have a class and
I have a string that is HTML encoded: '''&lt;img class=&quot;size-medium wp-image-113&quot;\ style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot;\
I have class with a member function that takes a default argument. struct Class
I have: class MyClass extends MyClass2 implements Serializable { //... } In MyClass2 is
I have class A: public class ClassA<T> Class B derives from A: public class
I have class Cab(models.Model): name = models.CharField( max_length=20 ) descr = models.CharField( max_length=2000 )
I have: class Car {..} class Other{ List<T> GetAll(){..} } I want to do:

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.