carlor wrote:
Hello again,
Thank you for all your help. Yes, a sample would be very much appreciated
Thank you,
Carlo.
if you create a copy of the CSharpTemplateSet.config, and alter that binding to another file and copy teh entityFactoryInclude.template file's contents into that file + your own code, you'll get your own custom factories
Ok here we go:
1) copy CSharpTemplateset.config in <llblgenpro folder>\Drivers\SqlServer\Templates to CustomCSharpTemplateset.config in the same folder
2) open CustomCSharpTemplateset.config in an editor (it's xml)
3) change the <name> contents so you'll recognize it in the dropdown in the generator config form in LLBLGen Pro
4) scroll down to this tag:
<templateBinding templateID="SD_EntityFactoryIncludeTemplate" templateFilename="..\..\..\SharedTemplates\C#\entityFactoryInclude.template" />
and alter it into:
<templateBinding templateID="SD_EntityFactoryIncludeTemplate" templateFilename="..\..\..\SharedTemplates\C#\myEntityFactoryInclude.template" />
and save the file.
5) copy <llblgen pro folder>\SharedTemplates\C#\entityFactoryInclude.template to myEntityFactoryInclude.template in the same folder and open it in a texteditor
6) you'll see one line:
return new <[CurrentEntityName]>Entity(new PropertyDescriptorFactory(), this);
change this into:
IEntity toReturn = <[CurrentEntityName]>Entity(new PropertyDescriptorFactory(), this);
toReturn.ConcurrencyPredicateFactoryToUse = new MyConcurrencyPredicateFactory();
return toReturn;
If you have a ConcurrencyPredicateFactory per entity, you can change ' new MyConcurrencyPredicateFactory' into 'new <[CurrentEntityName]>ConcurrencyPredicateFactory' to get the entity name generated into the call. Save the file.
Now, when you generate code, select your custom csharp template set and generate code. Your selfservicing entity factories now will create the concurrency predicate factory classes as well. Place your concurrency predicate classes in the same namespace: <rootnamespace>.FactoryClasses, so your code will be compilable.