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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:55:07+00:00 2026-05-27T05:55:07+00:00

I had View strongly type of my class Usario Defined like this public partial

  • 0

I had View strongly type of my class Usario Defined like this

public partial class Usuario
{
    public Usuario()
    {
        this.Campana = new HashSet<Campana>();
    }

    public int IDUsuario { get; set; }
    public int IDPerfil_FK { get; set; }
    public string Nombre { get; set; }
    public string Password { get; set; }
    public bool Activo { get; set; }

    public virtual Perfil Perfil { get; set; }
    public virtual ICollection<Campana> Campana { get; set; }
}

Now what i want to know is how can I avoid the validations of the class campana which is related with the class Usuario in the view, because when I doing ModelState.IsValid the Model validates the attributes of the class Usuario and also of class the Campana

  • 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-05-27T05:55:08+00:00Added an answer on May 27, 2026 at 5:55 am

    The correct way of doing this is to use view models.

    You already have Usuario class, now you implement the view model, which will only hold the properties you want to pass to the view. Something like:

    public class UsuarioProfileViewModel
    {
        public int IDUsuario { get; set; }
        public string Nombre { get; set; }
        public bool Activo { get; set; }
    
        // Other properties for that view
    }
    

    Now on the controller:

    public ActionResult UsuarioProfile(UsuarioProfileViewModel model) {
    {
        // Fill the missing properties for the model (when needed)
    
        View(model);
    }
    

    This way you only pass to the view the needed data. Data annotations work for view models exactly the same way as any other class.

    model is initialized by MVC and properties are filled in with incoming data, through routeValues, so you can do something like this:

    @Html.Action("UsuarioProfile", new { UsuarioID = 10 })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We had a View Model that looked like this: public class myViewModel { public
I had a single view with an each helper similar to this: <table class=select-sect
Let's suppose I had a view, like this: CREATE VIEW EmployeeView AS SELECT ID,
[QueryInterceptor(Somethings)] public Expression<Func<Something, bool>> OnSomethings() { // Code here } I had a view
I have a view that is not strongly typed. However I have in this
I just finished a class on InfoPath where the teacher had a grim view
I created a View based on a strongly typed model class in my MVC4
I have the following code in a partial view: @model MyOrganization.MyApp.Models.ProductListing @using (Ajax.BeginForm(TagProduct, new
I had created the following view, SELECT currency_cd, SUM(comprate) AS salary, employee_code, (SELECT SUM(c.comprate)
Has anyone had a go at creating a view that sorts a collection? The

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.