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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:12:20+00:00 2026-06-09T14:12:20+00:00

I am really struggling with getting two tables I have joined to show in

  • 0

I am really struggling with getting two tables I have joined to show in a view (I just want to show the customer name which comes from the customer tables and the bill status from the bill table – both of which are joint on a CustomerId primary key). I spent ages researching this and came to the conclusion of creating another model just for this view which I did however in my controller when I try and use the following:

Function ShowAll() As ViewResult
    Dim BillQuery = From d In db.Bills
                    Join c In db.Customers On d.CustomerId Equals c.CustomerId
                    Select c.CustSurname, d.BillStatus

    Dim BillList As List(Of BillView) = BillQuery.ToList()

    Return View(BillList)
End Function

I get an error:

Value of type ‘System.Collections.Generic.List(Of )’ cannot be converted to ‘System.Collections.Generic.List(Of Laundry.BillView)’

Here are my Bill and BillView models:

Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations

Public Class Bill

    'Key
    Public Property BillId() As Integer

    'Others
    <Required()>
    <Display(Name:="Customer ID")>
    Public Property CustomerId() As String

    <Required()>
    <Display(Name:="Bill Status")>
    Public Property BillStatus() As String

End Class

Public Class BillView

    Public Property CustSurname() As String

    Public Property BillStatus() As String

End Class

And Customer Model:

Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations

Public Class Customer

'Key
Public Property CustomerId() As Integer

'Others
<Display(Name:="Group ID")>
Public Property GroupId() As Integer

<Required()>
<Display(Name:="Firstname")>
Public Property CustFirstname() As String

<Required()>
<Display(Name:="Surname")>
Public Property CustSurname() As String

<Display(Name:="Email")>
Public Property CustEmail() As String

<Display(Name:="Cellphone")>
Public Property CustCellphone() As String

<Display(Name:="Address")>
Public Property CustAddress() As String

<Required()>
<Display(Name:="Status")>
Public Property CustStatus() As String

<Required()>
<Display(Name:="Account Balance")>
Public Property AccBalance() As Double

<Required()>
<Display(Name:="Loyalty Ammount")>
Public Property LoyaltyAmount() As Double

<Required()>
<Display(Name:="Customer Discount")>
Public Property PersonalDiscount() As Double


End Class
  • 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-09T14:12:21+00:00Added an answer on June 9, 2026 at 2:12 pm

    It looks like your first LINQ query is returning an anonymous type which can’t then be cast to List(Of BillView). Try the following code to return a collection of BillView models prior to the cast (note the added syntax Select New BillView With {}).

    Function ShowAll() As ViewResult
        Dim BillQuery = From d In db.Bills
                        Join c In db.Customers On d.CustomerId Equals c.CustomerId
                        Select New BillView With {.CustSurname = c.CustSurname, .BillStatus =  d.BillStatus}
    
        Dim BillList As List(Of BillView) = BillQuery.ToList()
    
        Return View(BillList)
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which I'm really struggling to compile: #include <stdio.h> #include
Really struggling to figure this out. Just trying to take in data from php
Im really struggling to get my head round this. Im using c#. I want
I'm really struggling with require.js and jquery mobile. I have a loosely based file
I'm really struggling with this. I have a viewdetails.php page, addnew.php page and a
I'm really struggling with this now, been on it for ages and asked two
I'm struggling with a really simple problem here. I want to generate a normal
really struggling to resolve this issue. using nhibernate Im trying to join two different
I have been struggling with this for a while and could really use some
I'm new to website building, so I'm really struggling! I have an image of

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.