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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:16:50+00:00 2026-05-16T00:16:50+00:00

Newbie-ish questions ahead: Where should I put my View Model declarations? I created a

  • 0

Newbie-ish questions ahead:

Where should I put my View Model declarations?

I created a file called “ViewModels.cs” in my Models folder.
I created a few View Model classes, including one called RatingViewModel:

using System;
using System.Collections.Generic;var
using System.Linq;
using System.Web;

namespace Web.Model
{
public class ViewModels
{

    public class RatingViewModel
    {
        public User Rater { get; set; }
        public Rating Rating { get; set; }
    }

}

}V

Now I’m trying to create a helper/service class function that returns a new RatingViewModel object.

I created a “RatingsHelpers.cs” file.
But when I try to crate a new RatingViewModel object, it has no idea what I’m talking about.
I can’t figure it out. Am I missing some reference? How can I create/return a new View Model object from my helper/service class?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using Web.Model;

namespace System.Web.Mvc
{
    public static class RatingsHelpers
    { 
        public static RatingViewModel functionname()
        { ..... }

But it doesn’t know what “RatingViewModel” is…!?!?!?

I just know this should be obvious.

Pulling my hair out,

Johnny

  • 1 1 Answer
  • 1 View
  • 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-16T00:16:51+00:00Added an answer on May 16, 2026 at 12:16 am

    To sum up:

    1. You’ve created a ViewModels class inside the Web.Model namespace. This class declares a nested class called RatingViewModel
    2. Inside the helper RatingsHelpers located in the System.Web.Mvc namespace you are trying to access the RatingViewModel class.

    You could achieve this by using ViewModels.RatingViewModel but I wouldn’t recommend you doing so. Nesting classes like this makes no sense.

    Instead you could place each view model class into a separate .cs file and put it directly into the Web.Model namespace:

    namespace Web.Model
    {
        public class RatingViewModel
        {
            public User Rater { get; set; }
            public Rating Rating { get; set; }
        }
    }
    

    Then inside the helper class use could use directly the RatingViewModel class.

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

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Newbie question: I just installed VisualSVN Server and created a repository. I noticed that
So I have already imported one XML-ish file with 3000 elements and parsed them
Newbie Java question - On all the posts for Auto Scaling the Text view,
Newbie question (I'm just getting started with Python and Pydev): I've created a project
Newbie to windows scripting. I need help running the .bat file on the command
newbie here .. wondering why in the table i get something called '[object node]'
C++ newbie here. I am a science guy writing a cfd (ish) code. I
Newbie Q. In my MainViewController, which is the first visible view. I have a
Newbie question about PostgreSQL. I'm migrating a MySQL/PHP app I've created, hosted on a

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.