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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:43:08+00:00 2026-05-21T22:43:08+00:00

I have a search result from the database, int searchTerm = xx var result

  • 0

I have a search result from the database,

int searchTerm = "xx"

var result = from orderLines in context.OrderLineSearch(searchTerm)
                                    select new
                                    {
                                        OrderNumber = orders.OrderNumber,
                                        OrderLineId = orders.OrderLineId
                                    }; 

I need to validate whether result contains many orders. That is I need to check whether multiple orders are returned or not.

I did the validation by storing the first order number in a variable and compared whether all the other rows contains only this order number. See below

string orderNumber = result.First().OrderNumber;

bool isValid = result.Where(x => x.OrderNumber != orderNumber).Count() == 0;

I want to know the best way to validate using LINQ? Can any one help me?

Thanks in advance.

  • 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-21T22:43:09+00:00Added an answer on May 21, 2026 at 10:43 pm

    May be you should to try group results by OrderNumber and then calculate Count?

    var result = from orderLines in context.OrderLineSearch(searchTerm)
                 group orderLines by orderLines.OrderNumber into g   
                 select g.Key     
    bool hasElements = result.Any();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an AutoCompleteExtender in ASP.NET/C# to retrieve data from my database, along with
We have a simple search on our site that uses MySQL fulltext search and
I have an External List over a products table in our database. I want
I'll explain my problem: I have a database table called country . It has
I have a search field that I want to autocomplete with data that I
I have a form which has a search feature - a single text field
I am currently developing a an application to allow users to search through a
I have some problems getting the custom formated JSON data into a dijit.form.FilteringSelect. It
I have two tables: A table of restaurants and a table of areas. The
I'm creating an API which will just use a get request to return some

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.