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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:01:45+00:00 2026-05-24T16:01:45+00:00

I have Order – Customers table i am using lazyloading for pulling order-customers information.

  • 0

I have Order – Customers table

i am using lazyloading for pulling order-customers information.

var ordercustomer = db.Orders.Include("customers").Where(c.orderid == id);

so i have pulled a ORDER WITH RELATED CUSTOMERS

I HAVE CUSTOMERID ,CUSTOMERCITY VALUES from the Form values

NOW MY TASK IS to check whether customerid and customercity exist in the
ordercustomer (result of the linq)

how would the linq query looks like?

  • 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-24T16:01:46+00:00Added an answer on May 24, 2026 at 4:01 pm

    I think you’re asking for something like this:

    db.Orders.Where(c => c.orderid == id)
        .Select(c => c.customers.Any(
            cu => cu.customerid == customerid && cu.customercity == customercity))
        .Single();
    

    This will produce a true or false value that tells you whether the given order has a customer associated with it that has the given ID and city. If the order doesn’t exist, an exception will be thrown.

    On a side note, when use use .Include, that is called eager loading. It is the opposite of lazy loading. Also, note that your original query doesn’t actually have any of the customers loaded yet because you haven’t evaluated it by calling .ToList or something similar. In the query I’ve provided, you aren’t required to use .Include because there is no reason to load all the Customer data into memory, when the database can do this work for you.

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

Sidebar

Related Questions

I have three tables Orders table and customers table and orderstatus table, both order
I have the Order table which contains information about a specific order, (when does
I have order table OrderId OrderStatusId CurrencyId PromotionCode ------------------------------------------------------ 137 5 1 123a-123d 138
I have a orders table that have order detail and the column named Category
I have an order table with the following columns: orderid, clientid, [columns for order
Let's say I have an Order table which has a FirstSalesPersonId field and a
Using LINQ to SQL, I have an Order class with a collection of OrderDetails.
I have a 'Purchase Order' class. It contains information about a single purchase order.
I have a table with two columns, customer id and order. Let's say I
I have a Order Details table. What I want to do is create 1

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.