Implements properties in interface

Posts   
 
    
mds avatar
mds
User
Posts: 33
Joined: 24-Sep-2006
# Posted on: 17-Sep-2016 12:31:02   

Often I have a number of Entities that share some methods and properties mapped to database fields (state, error message ...): I would like to assign to these a common interface in order to standardize the procedures that manages them. I can not use inheritance because they already come from other classes and Vb.Net does not support multiple inheritance.

For this I thought to define an interface to implement in each of these, but I'm not able to map properties generated by LLBLGen. The idea is this:


Public Interface ICommon
    Property State as Integer
    Property ErrorMessage as String
    ....
end Interface

Public Partial class AEntity
    Inherits BEntity
    Implements ICommon
    
    Property State as Integer Implements ICommon.State 
....
End Class

I Cannot implement in Partial Class this property because it's generated in another file by LLBLGen

Any suggestion on best practices to resolve this situation ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Sep-2016 20:16:44   

Mmm, yes, that's a problem indeed with VB.NET as you need to explicitly map properties to interfaces. In C# the compiler figures it out.

Let me see whether we can think a workaround for this scenario.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 21-Sep-2016 15:15:49   

Sadly that's a problem with VB.NET and can't be solved, only with custom templates which is a long route. The templates also will be complex as you need logic to test whether a field is in an interface you want to emit code for...

Sorry I don't have better news for you.

Frans Bouma | Lead developer LLBLGen Pro