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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:13:41+00:00 2026-05-18T02:13:41+00:00

For example DB with 2 Tables Book [BookId (int), Title (nvarchar), ShowInWebshop (bit)] and

  • 0

For example
DB with 2 Tables

Book [BookId (int), Title (nvarchar), ShowInWebshop (bit)] and 
InventoryDetail [InventoryDetailId (int), BookId (int), Quantity (int)]

Execute: SELECT * FROM Books LEFT JOIN InventoryDetails ON books.BookId = InventoryDetails.BookId

The output shows all Book columns and related InventoryDetails columns (including the InventoryDetails.BookId column)
..so far so good …
Trying to transform this query into a Linq one (using LinqPad, comparing several examples, common sense, etc.) I compilated the following generic List (because I wanted a present a list)

private List<Book> Books(int count){
    var books = webshopDB.Books
        .Join<Book, InventoryDetail, int, Book>( webshopDB.InventoryDetails, 
            b => b.BookId, 
            i => i.BookId,
            (b, i) => b )
        .Where(b => b.ShowInWebshop == true)
        .Take(count)
        .ToList();
    return books
}

This module returns a list of books! Not the one I expected, though! It returns only book details such as Title and ShowOnSite NOT the details from the InventoryDetail table: Quantity

What do I forget?

  • 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-18T02:13:42+00:00Added an answer on May 18, 2026 at 2:13 am

    The result how it works so far …

    public ActionResult Index()
    {                
        // This return a list of tuples {(WebshopDB.Models.Book, WebshopDB.Models.InventoryDetail)}
        // Each tuple containing two items: 
        // > Item1 {WebshopDB.Models.Book}
        // > Item2 {WebshopDB.Models.InventoryDetail}
        var tuple_books = ListOfTuples_BookInventoryDetail(5);
        ...
        // next step(s)
        // add a ViewModel viewmodel
        // ...
        return (viewmodel);
    }
    
    private List<Tuple<Book, InventoryDetail>> ListOfTuples_BookInventoryDetail(int count)
    {
       var list_of_tuples = new List<Tuple<Book, InventoryDetail>>();
    
       var showbooks = webshopDB.Books
         .Join(webshopDB.InventoryDetails, b => b.BookId, i => i.BookId, (b, i) => new { b = b, i = i })
         .Where(o => (o.b.ShowInWebshop == true))
         .Where(o => o.b.BookThumbUrl.Contains(".jpg"))
         .OrderByDescending(o => o.b.OrderDetails.Count())
         .Take(count);         
    
      foreach (var item in showbooks)
      {
        list_of_tuples.Add( Tuple.Create<Book, InventoryDetail>( (item.b), (item.i) ) );
      }
      return list_of_tuples;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is based on the example from the book: Pro WPF and Silverlight MVVM
Rails noob here. I have a rails application with (in this example) three tables.
In this example we have 3 related tables on a SQLite database: CREATE TABLE
I have 2 tables in my database, for example: Table1: id (PK), data1 and
For example, let's say I have the following two tables: Table1: Id ---- 1
I have two tables, for example: Table A Table B ======= ======= Name |
Say for example, I have the following two tables: TableA { _id } TableB
I have an example database, it contains tables for Movies, People and Credits. The
To explain by example, take two tables, A and B Table A id foo
I have 3 tables in my database, for example with such names: TableA, TableB,

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.