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

The Archive Base Latest Questions

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

I have An EntityModel that is named ECommerceEntities that contains several entities. If I

  • 0

I have An EntityModel that is named ECommerceEntities that contains several entities. If I want to use this model in a view in asp.net mvc, Can I pass ECommerceEntities instance to view or Sould I pass one entity in ECommerceEntities.

I mean :

//Can I use this?
public ActionResult Index()
{
   ECommerceEntities entity = new ECommerceEntities();
   return View(entity);
}

or

//Should I use this?
public ActionResult Index()
{
   ECommerceEntities.OneEntity one_entity = new ECommerceEntities.OneEntity();

   //filling one_entity here and then send to view

   return View(one_entity );
}

Thanks.

  • 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-01T07:27:08+00:00Added an answer on June 1, 2026 at 7:27 am

    If you are asking if it is possible, it is possible to do both. Yes, both options will work. However if you only need the sub entity in the view, I would just pass the sub entity into the view. No use in passing in more than needed right?

    Do not forget that in MVC whatever object you pass in to your view,(EcommerceEntities for example) can have its properties set in the post by MVC’s automatic model binding which maps data from the post into the object you pass into the view.

    So, this means that someone can hijack the http post and can fill in EcommerceEntities and its sub entities with various bits of random data of their choosing if you are not careful and you may accidentally save this data to your db because you did not expect some of these properties to get set.

    So, when working in MVC you have to protect properties that are not being used in your view but are passed into the view to ensure that nobody has injected them.

    If you do decide to pass in EcommerceEntities, make sure that you use whitelisting or look at MVC’s bind attribute to protect your data when your entity is posted back to your controller.

    Because of the work involved in protecting that much extra data, I would say that the sub entity would be best if the screen will populate correctly just off of the sub entity object.

    Hopefully this is helpful.

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

Sidebar

Related Questions

I have a EntityModel created from ADO.NET that connects to my database. I want
I am working on asp.net application and I have generated entity model (edmx) from
this.entityModel.Entities is a source to my datagrid(agdatagrid) . I have kept AutoGenerateColumns=False . i
I have an ADO .Net Entity Data Model for my database. In this Model
Some quick questions: So I have this LogInWindow dialog that I use to collect
I have a variable that contains an integer which I then want to save
I have a Entity model that includes a large number of lookup entities. All
I have an entity model with User and Person entities, such that each User
I have some data being pulled in from an Entity model. This contains attributes
I have a table named X that is already mapped to my Entity Model.

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.