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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:47:49+00:00 2026-06-14T02:47:49+00:00

I created a class from a database stored procedure using reflection and I want

  • 0

I created a class from a database stored procedure using reflection and I want to be able to display the contents of the data table unto a razor view without using entities or having to create a strongly typed model for the class. Right now I’m doing the following:

public static List<object> GetPeople()
{
    DataTable dt = DataAccess.GetPersons();

    List<object> obj = MapDataTableToPerson(DataAccess.GetPersons());

    return obj;
}

private static List<object> MapDataTableToPerson(DataTable dt)
{
    List<object> returnClassObject = new List<object>();

    Type typeClass = CreateClassFromDT(dt);


    foreach (DataRow dr in dt.Rows)
    {
        object obj = Activator.CreateInstance(typeClass);

        foreach(string columnName in ColumnNames)
        {
            PropertyInfo property = typeClass.GetProperty(columnName);

            property.SetValue(obj, dr[columnName], null);
        }

        returnClassObject.Add(obj);
    }

    return returnClassObject;
}

I call GetPeople from the controller and pass unto a view, but I have no clue on how to get the values from the created class in Razor, if anyone can help it will be greatly appreciated.

  • 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-14T02:47:50+00:00Added an answer on June 14, 2026 at 2:47 am

    Pass the DataTable model to the view and loop through the columns and rows. I don’t think you need to use reflection, just get a DataTable from your database.

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

Sidebar

Related Questions

I want to do following: Make Oracle stored procedure for read all data from
Let's say I have created two objects from class foo and now want to
I am using the following code to consume a CUBRID database java stored procedure.
I have a C# app that is reading data from a stored procedure and
i created a class derived from CheckedListBox so i can change item height as
I have created a class derived from NSImageView. However, the classes's constructor (init) is
I created a class where extends from ViewFlipper. When I try to instantiate on
I have created an ASP.NET class derived from the standard WebControls.TextBox , with the
I have built up an array of objects, created from a class, I wrote
Say I've got a domain model created from C# classes like this: public class

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.