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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:15:20+00:00 2026-06-05T06:15:20+00:00

in an ASP.NET MVC3 web application. I have a view. the view has a

  • 0

in an ASP.NET MVC3 web application.

I have a view. the view has a IEnumerable model.

I need to loop through all the model’s items and show the item.Name

The view:

@model IEnumerable<Object> 
@{
    ViewBag.Title = "Home";
}

@foreach (var item in Model)
{ 
    <div class="itemName">@item.Name</div>
}

In the controller, I use Linq to entities to get the list of objects from the database.

The Controller:

public ActionResult Index()
{
    IEnumerable<Object> AllPersons = GetAllPersons();
    return View(AllSurveys);
}

public IEnumerable<Object> GetAllPersons()
{
    var Context = new DataModel.PrototypeDBEntities();
    var query = from p in Context.Persons
                select new
                {
                    id = p.PersonsId,
                    Name = p.Name,
                    CreatedDate = p.CreatedDate
                };
    return query.ToList();
}

When I run I get this error:

 'object' does not contain a definition for 'Name' and no extension method 'Name' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

How can I access the “Name” Property of the model items?

Thanks a lot for any help

  • 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-05T06:15:21+00:00Added an answer on June 5, 2026 at 6:15 am

    Create a strong type for your method return.

    public class MyObject {
        public int id {get;set;}
        public string Name {get;set;}
        public DateTime CreatedDate {get;set;}
    }
    
    public IQueryable<MyObject> GetAllPersons() 
    { 
        var Context = new DataModel.PrototypeDBEntities(); 
        var query = from p in Context.Persons 
                    select new MyObject
                    { 
                        id = p.PersonsId, 
                        Name = p.Name, 
                        CreatedDate = p.CreatedDate 
                    }; 
        return query;
    } 
    

    … Then update your view to reflect the new model …

    @model IQueryable<MyObject> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC3 web application with C# and Razor. Through a form
I have an ASP.Net MVC3 web application written in C#. I have one ActionResult
I have a asp.net MVC3 web application in which i search for a certain
This is about asp.net mvc3 web application. We have used Object cache to store
We have an ASP.NET MVC3 web application. We generate HTML5 pages. And now, we
I am new to unit testing. I have a web application using asp.net mvc3
I've written a simple web application using asp.net mvc3 and I have a login
i am working on asp.net mvc 3 web application and i need to view
I have created blank Asp.Net-MVC 3 web application and want to write my own
I am writing a web application on Asp.Net MVC 3. Assume that we have

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.