Results 1 to 6 of 6

Thread: [RESOLVED] How to create object for an entity class?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Location
    India, Kerala, Calicut
    Posts
    242

    Resolved [RESOLVED] How to create object for an entity class?

    I have an Entity class names Users and i need this to be called at a View Names Create.

    How can i do that?
    I need to call the properties of Users class

    Pls help me....

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: How to create object for an entity class?

    Create is almost exactly the same as Edit except that you simply create a new, blank instance of your class instead of getting a populated on from the database. This is something that you'd know already if you had been through a decent tutorial, which I strongly recommend that you do. Here's the one that I used when I started:

    http://www.asp.net/mvc/tutorials/old...inner-tutorial

    C# code and ASPX syntax but the principles are all the same for VB.NET and Razor as well. Your question is covered in chapter 5.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: How to create object for an entity class?

    Here's a more up-to-date tutorial:

    http://www.asp.net/mvc/tutorials/mvc...o-aspnet-mvc-4

    It mentions the Create action/view very briefly in chapter 5 also, mostly saying that it's just like Edit except for passing an empty model object.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Location
    India, Kerala, Calicut
    Posts
    242

    Re: How to create object for an entity class?

    Thank you very much for the tutorial JMCilhinney.

    But here in this tutorial Model class's properties is calling from View. But here i need have a seperate project named Entity and inside that project the Users class. I already refered this project to my main project. and in View i have used the following code to use this Users class's properties's access

    @using Entity;

    and for this Entity's class i need to access in the view. For that i dont know how to create an object for this.

    for model class i know by using the following line we can do
    @model namespace.models.classname

    but here i dnt know

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: How to create object for an entity class?

    I don't really know what you're asking. You specify the type of the model in the view and you create an instance of the model in the controller. None of that is dependent on where the model is defined. Just use the full name of the model's type.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Location
    India, Kerala, Calicut
    Posts
    242

    Re: How to create object for an entity class?

    The problem was the class i have created wasnt under the Model. So that made me confused. now its ok.
    i put it as
    @model Entity.Users

    Its working
    Thank you so much once again.
    Since am new to vb.net, you always there to correct me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width