Search code examples
vb.netentity-frameworkinheritancepartial-classes

Create an instance of a list of Class (1) that inherits from another list of class(2) with a list from the other (2)


Question Seems Confusing so here is the code:

Partial Public Class Users
    Inherits vw_UserLocations
    Implements INotifyPropertyChanged

The Users inherits from vw_UserLocations. I wanted to create an istance of Users from vw_UserLocations

Using db As New AdjustmentEntities

            userLocations = Users.NewUsersList(db.vw_UserLocations.ToList)

But an error comes up saying that it cannot convert from one to the other


Solution

  • What I did was changed the Users Class to a partial class of the one i was inheriting Then in the code i just created a new instance of the vw_UserLocations class.

    Partial Public Class vw_UserLocations
       Implements INotifyPropertyChanged
    
    Dim userLocations = db.vw_UserLocations.ToList
    

    I learned that Partial classes should not use inheritance, in this specific situation.