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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:51:39+00:00 2026-06-01T07:51:39+00:00

I am working on a web based penny auction portal. I am using PetaPoco

  • 0

I am working on a web based penny auction portal. I am using PetaPoco as my data access class library with Asp.net MVC 3 architecture. I am facing an issue with multi-table data pull using stored procedure. I have created a view model POCO for mapping stored procedure fields, that I need on the front end.

View model:

public class BiddersViewModel
{
    public Guid UserId { get; set; }
    public String UserName { get; set; }
    public DateTime LastActivityDate { get; set; }
    public int NumberOfBids { get; set; }
    public int AuctionId { get; set; }
    public int BidId { get; set; }
    public decimal BidAmount { get; set; }       
}

Controller

public ActionResult Index()
{
    var context = new PetaPoco.Database("DataContext");
    return View(context.Query<dynamic>("exec udsp_Bidders_SelectAll"));
} 

What I need

I need to pull the data from the database with multiple joins and display on the view using stored procedure (using my view model 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-01T07:51:40+00:00Added an answer on June 1, 2026 at 7:51 am

    If your stored procedure returns the same column names as you use in your POCO class, you can change your code to:

    public ActionResult Index()
    {
        var context = new PetaPoco.Database("DataContext");
        return View(context.Fetch<BiddersViewModel>("exec udsp_Bidders_SelectAll"));
    }
    

    and your view should work as expected, because you’re likely having a strong type view with defined model type as Ienumerable<BiddersViewModel>.

    Don’t worry in case your stored procedure returns more columns that you defined within your POCO view model class. Just make sure that those that you wan’t mapped have correct names (or use ColumnAttribute to map them to properties).

    Regarding Fetch/Query difference is just that if you use Fetch you will be reading records in your controller action, but if you use Query and pass that to your view, you will be reading records in the view. It’s usually a better practice to prepare the data in controller action and use that data in the view. To support this pattern you should either use Fetch or Query<T>().ToList() in your controller action.

    But if you need to manipulate those results for some reason in the view (if it can’t be done any other way) then use Query and pass actual enumerator to view which will then manipulate results and read them accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web-based application using asp.net 4.0. I have some dlls
I'm working on a web-based academical evaluation project (VS2010,C#,ASP.NET). Users can enter the web
I am working on a web-based program, using Java. I am not sure exactly
I'm working on a web-based application using mySQL, and I've used it in the
The environment of my application: web-based, Spring MVC+Security, Hibernate, MySQL(InnoDB) I am working on
Am working on web based Job search application using Lucene.User on my site can
I'm working on a web-based project that users will access after having been authenticated
I am working on a web based application using php (not using Java), in
I'm working with the Indigo library for a web based chemistry project. Long story
I'm working on a web-based contest which is supposed to allow anonymous users to

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.