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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:34:34+00:00 2026-06-01T14:34:34+00:00

With ASP .NET MVC3. In my controller I have this portion of code MasterMindDnetEntities

  • 0

With ASP .NET MVC3.

In my controller I have this portion of code

    MasterMindDnetEntities context = new MasterMindDnetEntities();
    List<MasterMindDnet.Games> Games = (from g in context.Games
                                        join u in context.Users on g.g_u_Id equals u.u_Id
                                        where u.u_Login == User.Identity.Name
                                        select g).ToList();
    @ViewBag.Games = Games;
    @ViewBag.GameCount = Games.Count;
    return View("Index");

In the controll, Games works fine as a list.

In my view I have:

@for (int i = 0; i < ViewBag.GameCount; i++)
{
    ViewBag.Games = ViewBag.Games[i];

At line ViewBag.Games = ViewBag.Games[i];, I get the exception :

Cannot apply indexing with [] to an expression of type
‘System.Data.Entity.DynamicProxies.

In a previous version I had i < ViewBag.Games.Count; instead of i < ViewBag.GameCount; and it said that ViewBag.Games does not have a definition for Count.

How could I solve this ?

Thank you for your 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-01T14:34:35+00:00Added an answer on June 1, 2026 at 2:34 pm

    Problem of dynamic proxies mean that you have to declare “statically” what’s in your ViewBag.

    So in your View, just make :

    @{
        List<MasterMindDnetGames> games = ViewBag.Games;
    
        for (var i = 0; i < games.Count; i++) {
           var game = games[i];//declare it in the scope you need
           //bla bla bla
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my web server code (invoked from ASP.NET MVC3 site's controller) to be
ASP.Net MVC3 is cool and all but I have this question more out of
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
This is about asp.net mvc3 web application. We have used Object cache to store
I'm reading the Pro ASP.NET MVC3 Framework book from Freeman and Sanderson and have
I have a controller / action in an ASP.NET MVC3 app. It handles the
I'm using jquerymobile and asp.net MVC3 razor. I'm somewhat new to this, but figuring
This is for an ASP.NET MVC3 web application. In RegisterRoutes I have the following
I need some help on this problem. It is about ASP.NET MVC3. I have
I am working on an asp.net mvc3 application with linq2sql. I have a List

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.