I use the entity classes of my edmx file for LINQ queries in my application.
I have come to the point where I need to add additional, business logical functionality/Properties to these classes. I wonder if I should do this via "Inherits" or "Partial Classing". I have tried it with Inherits and it works relatively good and I also would prefer to use "real" inheritance.
The problem now is that I can not add any records with the "AddToTablename" Sub of the entitiy class anymore because the inheriting class is situated in another namespace than the entity class.
Is there a solution like casting the objects (which I tried already but maybe made a mistkae) ?
Here is exmaple code:
Code: Select all
'Generated entity class
Namespace Data
Partial Public Class DB
Inherits Global.System.Data.Objects.ObjectContext
...
...
...
End Class
End Namespace
'Inheritance class
Namespace Business
Public Class USER
Inherits MyApp.Data.USER
'Custom functions
Public Function Check() As CheckFeedback
...
...
End Function
End Class
End Namespace
'Code to add User
Imports MyApp.Business
Dim oUser as USER
...
...
LinqAccess.AddToUSER(oUser)
LinqAccess.SaveChanges()