c# interface generation for adapter

Posts   
 
    
Posts: 1
Joined: 13-Jul-2007
# Posted on: 13-Jul-2007 18:36:20   

I'm sure I remember this being available before. Is there a task/method to generate an interface for each entity object?

Thanks in advance if you can point me in the right direction

Posts: 94
Joined: 26-Feb-2006
# Posted on: 13-Jul-2007 20:53:24   

I´ve been pushing for it a while ago but it got not enough response so I rolled my own cause I want a clean separation between BL and PL nice sideeffect is no need of ORMSupport in my PL..smile

any addition are welcome ...

Frans how do I get the meta data of the data fields e.g. max length of strings etc. in the TDL Template? As I want to add it as Attributes to my Interface generated with the attached template..

Goal is to have complete technology agnostic representation of the data model.

It´s VB but you should be able to convert it in a breeze.. btw. C# supports partial interfaces VB does not for what reason I don´t know but in C# you can do you code organisation by generating the data model interface and add additional custom interfaces via partial interface in different files (no worries about separation of generated and written code)


' ////////////////////////////////////////////////////////////////////////////////////////////////////////
' // This is generated code. 
' ////////////////////////////////////////////////////////////////////////////////////////////////////////
' // Code is generated using LLBLGen Pro version: <[LLBLGenVersion]>
' // Code is generated on: <[Time]>
' // Code is generated using templates: <[TemplateName]>
' // Templates version: <[TemplateVersion]>
' ////////////////////////////////////////////////////////////////////////////////////////////////////////

    ''' <summary>
    ''' Interface for the entity '<[CurrentEntityName]>'.
    ''' </summary>
    '''[DataContract]
Public Interface I<[CurrentEntityName]> <[ If IsSubType ]>
    Inherits I<[ SuperTypeName ]> <[ EndIf]> 
    '[Object Data Member]
<[Foreach RelatedEntity OneToMany CrLf]>
    <[If Not MappedFieldRelationIsHidden]>
    '1:n
    ReadOnly Property <[MappedFieldNameRelation ]>Collection As IList(Of I<[RelatedEntityName]>) 
    <[EndIf]> 
<[NextForeach]>
<[Foreach RelatedEntity ManyToMany CrLf]>
    <[If Not MappedFieldRelationIsHidden]>
    'm:n
    ReadOnly Property <[MappedFieldNameRelation]>Collection As IList(Of I<[RelatedEntityName]>) 
    <[EndIf]>
<[NextForeach]>
<[Foreach RelatedEntity ManyToOne CrLf]>
    <[If Not MappedFieldRelationIsHidden]>
'n:1
    Property <[MappedFieldNameRelation]> As I<[RelatedEntityName]> 
    <[EndIf]>
<[NextForeach]>
<[Foreach RelatedEntity OneToOne CrLf]>
<[If Not MappedFieldRelationIsHidden]>
'1:1
Property <[MappedFieldNameRelation]> As I<[RelatedEntityName]> 
        <[EndIf]>
<[NextForeach]>
<[Foreach EntityField CrLf]> 
    '[ Scalar Data Member]
        <[If IsPrimaryKey ]><[ If IsSubType ]>Shadows <[ EndIf ]><[ EndIf ]>Property <[EntityFieldName]> As <[If IsNullable]><[If IsValueType]>Nullable(Of <[TypeOfField]>)<[Else]><[TypeOfField]><[EndIf]><[Else]><[TypeOfField]><[EndIf]>  
<[NextForeach]>


'Validation Interface
<[ If IsSubType ]>Shadows <[ EndIf ]>Function Validate() As Boolean
<[ If IsSubType ]>Shadows <[ EndIf ]>ReadOnly Property ValidationErrors As IList(Of System.String)


End Interface

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 14-Jul-2007 12:59:36   

adrianporger wrote:

I´ve been pushing for it a while ago but it got not enough response so I rolled my own cause I want a clean separation between BL and PL nice sideeffect is no need of ORMSupport in my PL..smile

any addition are welcome ...

Frans how do I get the meta data of the data fields e.g. max length of strings etc. in the TDL Template? As I want to add it as Attributes to my Interface generated with the attached template..

You can in certain loops. It's the meta-data of the target field, which are also used to generate the persistence info provider classes simple_smile .

So check the persistenceInfoProvider.Template for details. You can run a loop like <[Foreach EntityField CrLf]> <[NextForeach]>

and in that loop you can access statements like <[SourceColumnMaxLength]> etc. See for details the SDK.

I'd use a .lpt template for this though if you want full flexibility. simple_smile You can use .lpt templates as includes inside a tdl template if you want to.

Thanks for sharing the template! simple_smile

Frans Bouma | Lead developer LLBLGen Pro