1 Replies - 10525 Views - Last Post: 03 August 2012 - 08:00 PM Rate Topic: -----

#1 mil1234  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 110
  • Joined: 01-February 09

Inheriting from multiple classes in a VIEW

Posted 01 August 2012 - 08:05 PM

Is it possibile to inherit from multiple classes in the same VIEW. i have many classes that mirror my database tables with linq to sql and as i m doing a register page(THE VIEW), which needs multiple classes i need to find a way to inherit more than 1?

tnx to all
Is This A Good Question/Topic? 0
  • +

Replies To: Inheriting from multiple classes in a VIEW

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: Inheriting from multiple classes in a VIEW

Posted 03 August 2012 - 08:00 PM

well you definitely cannot inherit from more than one class in C#. You can implement multiple interfaces but you can only inherit from one class. However, if you are needing to pass multiple objects to your view you can do so using a composite class. This would allow you to pass a single object that contains instances of the different objects you need rather than using a class that inherits from all of the different classes you need to pass to the view.

public class RegisterViewModel
    public ClassOne ExampleOne {get;set;}
    public ClassTwo ExampleTwo {get;set;}
    public ClassThree ExampleThree {get;set;}

Then in the view would access each object using dot notation just as you would any other property.


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1