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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:04:57+00:00 2026-06-15T13:04:57+00:00

I have one LINQ Query. I dont know much about LINQ. I was working

  • 0

I have one LINQ Query. I dont know much about LINQ. I was working on Entity Framework. I have to get the records based on the Input Date (CDate). Assume the structure is something like this.

          Table A                                Table B

       Id          CDate                   Id            No         A_Id

       1          11-11-2012                1            1001         1
       2          11-11-2012                2            1002         1
       3          12-12-2012                3            1003         2

Based on this table definition if the input date is some like 11-11-2012, the output should be like,

    Table B

    Id        No

     1        1001
     2        1002
     3        1003

something like the above. I have tried this one but its not working. Pls have a look at this code.

Code

     var model = (from x in Db.TableB
                  where x.TableA.CDate == 'Input Value'    // 11-11-2012
                         select new ViewModel
                         {
                         }).Tolist();

Please tell me the possibilities that i can write code to get the Distinct value for the appropriate input date.

Thanks,

  • 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-15T13:04:58+00:00Added an answer on June 15, 2026 at 1:04 pm

    Do you want some thing like this?

    var model = (from x in Db.TableB
         join y in Db.TableB on x.ID equals y.ID
         where x.TableA.CDate == 'Input Value' //11.11.2012
         select new  
         {  
             x.ID,
             y.No 
         }).ToList();
    

    Output:

    Id        No
    
     1        1001
     2        1002
    

    UPDATE

    var model = (from x in Db.TableB
                where x.TableA.CDate == 'Input Value' //11.11.2012
                select new  
                {  
                    x.ID,
                    x.No 
                }).ToList();
    

    Sorry, first, I thought there is one-to-one relationship. But your entity has one-to-many relationships. Your codes are correct, only add

    select new  
    {  
         x.ID,
         x.No 
    }).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one question about LINQ, I dont know how to get the result
I have a LINQ to SQL class VoucherRecord based on a simple table. One
I have some Linq code and it's working fine. It's a query that has
I have been using linq in combination with entity framework for a few months
I have two LINQ statements that I would like to make into one, but
I have been using Linq to SQL for a while now on one of
I have an XML file that I'm trying to parse with Linq-to-XML. One of
I have a datagrid populated by a Linq query. When the focused row in
Okay so here's the thing: I have a linq query which loads approx. 1000
I know there have been numerous questions here about inline sql vs stored procedures...

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.