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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:23:52+00:00 2026-05-27T12:23:52+00:00

This is the method in my Model : public IList<Customer> GetProfileCustomer(int id) { var

  • 0

This is the method in my Model :

 public IList<Customer> GetProfileCustomer(int id)
    {
        var list_customer = from c in DataContext.Customers
                            where c.ID == id
                            select c;
        return list_customer.ToList();
    }

And this is what I did in my controller :

   public ActionResult ShowProfile()
    {
        List<CustomerModels> cus = new List<CustomerModels>();

        return View();
    }

I created the object cus to call the method GetProfileCustomer() in the model, but I cannot do that. When I write : cus.GetProfileCustomer, It is error.

  • 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-27T12:23:53+00:00Added an answer on May 27, 2026 at 12:23 pm

    Your major issue is the line:

    List<CustomerModels> cus = new List<CustomerModels>();
    

    That is not creating an instance of CustomerModels, so you can’t call that method on it. You would have to do something like:

    public ActionResult ShowProfile()
    {
        cus = new CustomerModels();
        var data = cus.GetProfileCustomer(123);
        return View(data);
    }
    

    However, in the MVC sense, I don’t think loading data from your Model is really the right approach. Typically the Controller has some reference to something else that loads and saves data. The Model is usually just a class with properties to hold the data.

    I would look at the “NerdDinner” sample project. For example, in these files:

    • DinnersController.cs (controller)
    • Dinner.cs (model)

    Note that DinnersController holds a reference to a dinner repository, which is the thing that queries the database.

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

Sidebar

Related Questions

I created one method in my model : public IList<Test> GetData(int IDCus){ var list
i have this in my BlogRepository public IQueryable<Subnus.MVC.Data.Model.Post> GetPosts() { var query = from
Can this method work? public String sayHello(){ return Hello.jsp?name= + laala; } I am
I have a method with the signature public void setFoo(int newFoo) in a model
I defined a model like this public class Planilla { [Key] public int IDPlanilla
So I have a method in a reservation model called add_equip. This method does
I am attaching a method to the post_save signal of my Django model. This
I have this widget: $this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' =>
Take this method /** * @return List of group IDs the person belongs to
I'd like to know, How Could I map (with fluent nhibernate) this model: public

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.