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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:57:16+00:00 2026-05-27T07:57:16+00:00

I am using .NET 4.0, MVC3 and entity framework 4.0 I need to pass

  • 0

I am using .NET 4.0, MVC3 and entity framework 4.0

I need to pass a database record of type “statement” to a view. The code to fetch the record is as below:

public ActionResult pdfStatement(string InvoiceNumber)

{

            ObjectParameter[] parameters = new ObjectParameter[1];

            parameters[0] = new ObjectParameter("InvoiceNumber", InvoiceNumber);

            return View(_db.ExecuteFunction<Models.Statement>("uspInvoiceStatement", parameters));            
        }

where “uspInvoiceStatement” is my stored procedure used to fetch “statement”

I have created a strongly typed view which receives the “statement”

< % @ Page Language="C#" Inherits="System.Web.Mvc.ViewPage < InvoiceSearch.Models.Statement >" %>

When i run the application i get an exception saying

    "The model item passed into the dictionary is of type 'System.Data.Objects.ObjectResult`1[InvoiceSearch.Models.Statement]',
 but this dictionary requires a model item of type 'InvoiceSearch.Models.Statement'. 

Help me to escape from this trouble.
“

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

    The error is surprisingly helpful – it tells you, you are sending ObjectResult<Statement> to the view asi viewmodel, while you should send Statement.

    Your _db.ExecuteFunction always returns ObjectResult<Statement>, so you need to take Statement from it, like this :

    var statementResult = _db.ExecuteFunction<Models.Statement>("uspInvoiceStatement", parameters);
    var statement = statementResult.SingleOrDefault();
    if (statement != null)
    {
        return View(statement); // isnt that nicer when you can see what your viewmodel is?
    }
    else
    {
        return View("NotFound");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an ASP.net MVC3 application using Entity Framework Code First and SqlCe4. I
I'm currently developing an app using ASP.NET MVC3 and Entity Framework 4.1 Code First
I am using Entity Framework 4.1 code first with ASP.NET MVC 3 and Razor
I'm using ASP.NET MVC 3 with the Entity Framework 4 code first approach and
I am using SQL Azure as database with code first technique of Entity framework
I am using Entity Framework 4.1 code first and ASP.NET MVC 3 and I
I am currently programming a ASP.NET MVC3 application, using Entity Framework 4. There are
I'm working on a page using ASP.NET MVC3, Razor and Entity Framework. I used
I have developed a project using MVC3 and Code first Entity Framework 4.0 as
I'm setting up a blog using Asp.net MVC3 and Entity framework 4. Most 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.