OK. Although Frans has tried to document all this in the SDK, I could not find an example of actually doing it, and had to poke around for a while to get the hang of it. Hopefully this will save you an hour or two. Here's what I did:
Went to C:\Program Files\Solutions Design\LLBLGen Pro\Drivers\SqlServer\Templates and found the config file for the template set I was using. In my case, that was CSharpTemplateSet.config. I made a copy of this, and called it something else. I need to change my names a little bit so... let's say "MyCSharpTemplateSet.config". Then I changed the binding for SD_EntityAdapterTemplate
from
"..\..\..\SharedTemplates\C#\entityAdapter.template"
to
"..\..\..\SharedTemplates\C#\myEntityAdapter.template"
plus I added these bindings:
<templateBinding templateID="Custom_EntityAdapterTemplate" templateFilename="..\..\..\SharedTemplates\C#\myCustomInclude.template" />
<templateBinding templateID="TraceSetEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myTraceSetEntityInclude.template" />
<templateBinding templateID="TraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myTraceEntityInclude.template" />
<templateBinding templateID="DateTimeTraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myDateTimeTraceEntityInclude.template" />
<templateBinding templateID="LatitudeTraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myLatitudeTraceEntityInclude.template" />
<templateBinding templateID="LongitudeTraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myLongitudeTraceEntityInclude.template" />
<templateBinding templateID="NumericTraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myNumericTraceEntityInclude.template" />
<templateBinding templateID="StringTraceEntityInclude" templateFilename="..\..\..\SharedTemplates\C#\myStringTraceEntityInclude.template" />
Then I went to C:\Program Files\Solutions Design\LLBLGen Pro\SharedTemplates\C#
and made a copy of entityAdapter.template and named it myEntityAdapter.template. Here I made several changes, using the TDL code. For example, I added namespaces:
<[If StringValueEquals CurrentEntityName "TraceSet, Trace, DateTimeTrace, LatitudeTrace, LongitudeTrace, NumericTrace, StringTrace"]>
// emitted by my template
using My.Namspace;
<[EndIf]>
then just under the class declaration
<[If StringValueEquals CurrentEntityName "TraceSet, Trace, DateTimeTrace, LatitudeTrace, LongitudeTrace, NumericTrace, StringTrace"]>
// emitted by my template
, I<[CurrentEntityName]>
<[EndIf]>
and further down
#region Included code
// emitted by my template
<# Custom_EntityAdapterTemplate #>
#endregion
Now remember I bound Custom_EntityAdapterTemplate to my own file. Here are the contents of that file.
<[If StringValueEquals CurrentEntityName "TraceSet"]>
<# TraceSetEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "Trace"]>
<# TraceEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "DateTimeTrace"]>
<# DateTimeTraceEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "LatitudeTrace"]>
<# LatitudeTraceEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "LongitudeTrace"]>
<# LongitudeTraceEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "NumericTrace"]>
<# NumericTraceEntityInclude #>
<[EndIf]>
<[If StringValueEquals CurrentEntityName "StringTrace"]>
<# StringTraceEntityInclude #>
<[EndIf]>
And the files I bound to each of the placeholders (e.g., "TraceSetEntityInclude") holds actual code to be emitted for that entity. This code would be the interface implementation and other code needed.
Note that I put a comment in anywhere I emit code, so I can easily search for it in the generated file. Also note that I believe I used a mixture of approaches here; I used the hook to "include" code in the output by binding Custom_EntityAdapterTemplate, but I also directly modified the (copy of) the template file.
One thing that is minorly annoying, IMHO, is all the extra blank lines that get generated into the output file. I used to wonder about these, but now I understand that when a line is evaluated, it will result in a newline being generated, even if the expression results in only whitespace. Makes the generated code look a little funky. I even thought about adding a task at the end (if this is possible) to collapse down the newlines, but I don't have the time, really. Frans, if you are reading this, please consider. (I am the most anal person on the forum and therefore likely the only one who would suggest this).
Also a FAQ that describes a "walk-through" like I just did would be nice.