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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:15:15+00:00 2026-05-27T05:15:15+00:00

How can I select data with such linq to sql code, it’s something wrong,

  • 0

How can I select data with such linq to sql code, it’s something wrong, i must compare WHERE, from st1 and st2, but something wrong. Also spaller didn’t light this variables in where

var st1 = (from a in db.RouteDetail
                          where a.Station == "Гродно"
                          select new 
                          {
                              a.Route,
                          });
                var st2 = (from c in db.RouteDetail
                          where c.Station == "Лида"
                          select new 
                          {
                              c.Route,
                          });
                var res = (from d in db.RouteDetail
                           where st1.Route == st2.Route
                           select d);

Help me to do this, please.

  • 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-27T05:15:16+00:00Added an answer on May 27, 2026 at 5:15 am

    I think what you mean to do is something like this :

    var st1 = (from a in db.RouteDetail
                          where a.Station == "Гродно"
                          select new 
                          {
                              a.Route,
                          });
    var st2 = (from c in db.RouteDetail
                          where c.Station == "Лида"
                          select new 
                          {
                              c.Route,
                          });
    

    Both st1 and st2 now contain IQueryable types which allow you to enumerate over them. I’m assuming that your two queries only return one result in which case:

    var station1 = st1.FirstorDefault();
    var station2 = st2.FirstorDefault();
    
    var res = (from d in db.RouteDetail
               where station1.Route == station2.Route
               select d);
    

    Will do what you need it to do (provided they return a result theres no safety here for null exceptions). If however there is more than one result, it will only return the first match. In which case you will need to work out all the possible compositions from the values in st1 and st2

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

Sidebar

Related Questions

I have a LINQ query such as: using(csv.......) { csv.Select(x => new Data() {
In past I use dynamic sql and datatable to get data from database. Such
In MySQL, how can you select data where every row meets a certain condition?
How can I select the first 4 rows of a data.frame : Weight Response
How can you go about updating a record without having to select the data
I'm trying to understand how LINQ can be used to group data by intervals
I need to implement an editable combobox where users can select existing values from
I need to update a row of alarms with Linq to SQL, which can
I have a data-structure such that: SecurityPolicy 1<---* SecurityPolicyRule Therefore, a SecurityPolicy can have
I need to get two fields from a database table (retrieved using linq-to-sql), one

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.