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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:38:59+00:00 2026-06-16T06:38:59+00:00

I have a problem getting result from a database by specific column value using

  • 0

I have a problem getting result from a database by specific column value using LINQ.

This is my table Customer(Id, Name, Surname, ExternalID). ExternalID is a varchar column with specific string pattern, for instance 01_johnDoe.

Let’s say that I want to get customer johnDoe and my mehod gets string johnDoe.

I’m able to do that by this way :

public<Customer> GetMeACustomer(string customerExternalID)
{
using(var context=new MyContext())
{

var customerObject=(from c in contex.Customer where c.ExternalID.Contains(customerExternalID)).Single()   

}

}

This code is not good enough simply because query sent to Database is using operator LIKE. This is slow (I have huge number of customer).
I couldn’t implement inside linq something like this :

   var example = ExternalIDFromDatabase.Substring(ExternalIDFromDatabase.IndexOf("_") + 1, customerExternalID.Count());

by this code I could simply say

var customerObject=(from c in contex.Customer where c.ExternalID.Substring(c.ExternalID.IndexOf("_") + 1, customerExternalID.Count())==customerExternalID).Single()

But it’s not working.
Any Ideas ?
Than you

  • 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-16T06:39:00+00:00Added an answer on June 16, 2026 at 6:39 am

    It should work when you replace customerExternalID.Count() with customerExternalID.Length or when you create local variable (let say customerExternalIDCount) and assign count to it. Probably provider tries to translate this Count call into SQL.

    BTW you probably want to use Substring method without specifing length. If there was for example 01_johnRobin and 02_johnRobins in database, you would get 2 results for johnRobin customerExternalID.

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

Sidebar

Related Questions

I have problem with getting rows from my database using Hibernate. When I would
I have a problem getting my data from database and foreach it. This is
i have a little problem while getting a value from database and post it
I'm using jqGrid and I have a problem getting Dynamic Linq to work. I
I have this function for getting users from database : function get_users_limited($offset, $limit) {
I have a little problem with getting all data from SQLite database and showing
I'm new to SQL. I have a simple problem with getting the results from
I have a problem with getting jquery to retrieve results from a WCF service.
I have a problem getting a private method using reflection. Even with BindingFlags.NonPublic and
I have this problem getting my newly created php project on Netbeans work on

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.