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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:49:18+00:00 2026-06-05T08:49:18+00:00

Scenario: const string srchFormatter = {0} {1} {2}; var result = from c in

  • 0

Scenario:

 const string srchFormatter = "{0} {1} {2}";

 var result = from c in db.ContactsDumps1s
                     where string.Format(srchFormatter, c.FirstName, c.MiddleName, c.LastName).Contains(txtSearch.Text.Trim())
                     select new { c.FirstName, c.MiddleName, c.LastName };

Error:

Method ‘System.String Format(System.String, System.Object, System.Object, System.Object)’ has no supported translation to SQL.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Method ‘System.String
Format(System.String, System.Object, System.Object, System.Object)’
has no supported translation to SQL.

Can anybody please let me know why am I not able to search in this manner & any alternatives for this search?

This is what I plan to achieve :

select FirstName, MiddleName, LastName 
from ContactsDumps1 
where FirstName+MiddleName+LastName like '%Search_String%'

by using LINQ.

  • 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-05T08:49:20+00:00Added an answer on June 5, 2026 at 8:49 am

    Seems like you’re doing a LINQ-to-SQL query, since your DB context is tied to a database connection. In doing this, you’re issuing a query to your database. Think about the query that you’re constructing:

    from c in db.ContactsDumps1s
                         where string.Format(srchFormatter, c.FirstName, c.MiddleName, c.LastName).Contains(txtSearch.Text.Trim())
                         select new { c.FirstName, c.MiddleName, c.LastName };
    

    Which probably translates to something like:

    SELECT FN, MN, LN
    FROM ContactsDumps1s
    WHERE 'FN FN FN' Contains SomeTextValue
    

    That doesn’t really translate well. I think what you’re trying to do is a LIKE – where FirstName Starts With SomeTextValue.

    So you may want to try:

        from c in db.ContactsDumps1s
        where c.FirstName.StartsWith(txtSearch.Text.Trim()) ||
              c.MiddleName.StartsWith(txtSearch.Text.Trim()) ||
              c.LastName.StartsWith(txtSearch.Text.Trim())
        select new { c.FirstName, c.MiddleName, c.LastName };
    

    I may not understand what you’re exactly trying to do, but hopefully this helps. Let me know if I’m missing something and I’ll clarify my answer.

    UPDATE: I updated my suggested LINQ statement to search FirstName, MiddleName or LastName for the text in txtSearch.

    UPDATE #2: I noticed your updated question and what you’re looking to do. Here’s an approach that may work for you:

    from c in db.ContactsDumps1s
    where (c.FirstName + " " + c.MiddleName + " " + c.LastName).StartsWith(txtSearch.Text.Trim())
    select new { c.FirstName, c.MiddleName, c.LastName };
    

    Using LINQPad, I did something similar and the generated SQL from it is:

    SELECT [t0].[FirstName], [t0].[MiddleName], [t0].[LastName]
    FROM [SalesLT].[Customer] AS [t0]
    WHERE (([t0].[FirstName] + @p0) + ([t0].[MiddleName] + @p0) + [t0].[LastName]) LIKE @p1
    

    That roughly translates to what you want to do.

    Hope this helps.

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

Sidebar

Related Questions

Scenario: User is viewing a screen with an image and some accompanying text in
Scenario: old legacy code in rpg have to consume data from a new web
From an external service I get objects with Date+Time fields as String 's in
If an input const string is being modified in some way (which is resulting
Imagine a scenario you have a text file with say 10000 rows in it
In the common diamond scenario: class MBase { public: MBase(int) {} virtual char const*
Scenario: At our company, we have enabled httpCompression for our website. This website (call
Scenario: I want to develop an application.The application should be able to connect to
Scenario: Windows server in a AD domain hosting a Subversion repository using SVNSERVE only
Scenario A SOAP web service provides an interface for retrieving documents and data. Security

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.