This is a migrated thread and some comments may be shown as answers.

T4 Code Generation question

1 Answer 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Harald Bacik
Top achievements
Rank 2
Harald Bacik asked on 20 Jun 2013, 12:59 PM
Hey

I am new about changing T4 templates. So, I hope, anyone out there could help me please with a step-by-step Information.
I want to Change the Code Template, so the following lines should be set as Friend and not Public

Public Sub New()
        MyBase.New(connectionStringName, backend, metadataSource)
    End Sub
         
    Public Sub New(ByVal connection As String)
        MyBase.New(connection, backend, metadataSource)
    End Sub
         
    Public Sub New(ByVal backendConfiguration As BackendConfiguration)
        MyBase.New(connectionStringName, backendConfiguration, metadataSource)
    End Sub
             
    Public Sub New(ByVal connection As String, ByVal metadataSource As MetadataSource)
        MyBase.New(connection, backend, metadataSource)
    End Sub
             
    Public Sub New(ByVal connection As String, ByVal backendConfiguration As BackendConfiguration, ByVal metadataSource As MetadataSource)
        MyBase.New(connection, backendConfiguration, metadataSource)
    End Sub

So, as I wrote above, I don't want to have this Sub New as public, I want it as Friend

THX for advise
Have a nice day

1 Answer, 1 is accepted

Sort by
0
Dimitar Tachev
Telerik team
answered on 21 Jun 2013, 04:59 PM
Hi Harald,

 
In order to achieve this you could follow the steps below:

1) Go to the Code Generation Templates folder of the Telerik OpenAccess ORM which could be found here:

<YourOpenAccessInstallDir>\dsl{YourVisualStudioVersion}\
CodeGenerationTemplates\VisualBasic

 e.g.
C:\Program Files\Telerik\OpenAccess ORM\dsl2012\
CodeGenerationTemplates\VisualBasic


2) Copy the DefaultTemplateVB.tt file and the Includes_ver.2 folder.


3) Paste them in the project containing your RLINQ file which you want to modify (e.g. in folder named OpenAccessTemplates).


4) Remove the custom tool settings from the properties of the DefaultTemplateVB.tt file.



5) Go to the ContextGenerator.ttinclude and modify the access modifiers of the constructors in the GenerateConstructorsAndMappingSource method.


6) Set the custom template from the Code Generation tab of the Model Settings of your Domain Model.


7) Save your RLINQ file in order to regenerate its classes.

For your convenience I also created a sample application demonstrating this approach - please find it attached.

Please bear in mind that the sample and the steps are based on our latest release Q2 2013 and you will need to update your OpenAccess ORM if you use an older version.

With this release you could also take advantage of our new code generation features. They are out-of-the-box generation of DataAnnotation attributes, implementing the INotifyPropertyChanged, INotifyPropertyChangind and the IDataErrorInfo interfaces.

I hope this helps. Do not hesitate to  contact us back if you need any further assistance.

Regards,
Dimitar Tachev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Tags
General Discussions
Asked by
Harald Bacik
Top achievements
Rank 2
Answers by
Dimitar Tachev
Telerik team
Share this question
or