I really have no idea.

I am trying to return a view with results from a Joined Table.

I keep receiving this error:

"The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[System.String[]]', but this dictionary requires a model item of type 'tacticMVC.crypto'. "

my controller code is as follows

 Function Details(Optional ByVal id As Integer = Nothing) As ActionResult
    If Request.IsAuthenticated = True Then

        'Dim cryptoes = db.cryptoes.Where(Function(c) c.key_email = HttpContext.User.Identity.Name()).ToList()
        'Dim crypto As crypto = db.cryptoes.Find(cryptoes(0).id_cypto)


        Dim crypto = (From c In db.cryptoes
                       Join con In db.consumers On c.id_consumer Equals con.id_consumer
                        Where c.id_consumer = 3
                      Select {c.key_email})

        Return View(crypto)
    Else
        Return HttpNotFound()
    End If
End Function

If I use just the 2 commented lines in the function the view returns fine but of course I can only get the data from one table. I need to join the tables and then return the data.

I've tried adding .toList(), .singleordefault() etc - does not solve anything

the vbhtml file:

@ModelType tacticMVC.crypto

<h2>Details</h2>
@Using Html.BeginForm("Action", "Controller", FormMethod.Post)
@<fieldset>

<div class="display-label">
    @Html.DisplayNameFor(Function(model) model.key_email)
</div>
<div class="display-field">
    @Html.DisplayFor(Function(model) model.key_email)
    something
</div>


</fieldset>
@<p>
    @Html.ActionLink("Edit", "Edit", New With {.id = Model.id_cypto}) |
    @Html.ActionLink("Back to List", "Index")
</p>
End Using

Related posts

Recent Viewed