billb wrote:
All right, I just downloaded the demo version yesterday and I'm quite impressed. I'm recommending a purchase.
I have one problem that I'm trying to get around but it seems like it's taking me way too long. I generated some code that I'm trying to use and I want to use my own connect string that I generate at runtime. I see many references to DataAccessAdapter, however, I don't have that class anywhere. So it appears as if I'm using the SelfService stuff (and I'm still trying to figure out what the better path for that is). Do I have to use the Adapter route if I want to change the connect string at runtime.
Thanks for the direction, help and a good product.
SelfServicing is not that good for doing this, adapter is meant for this. It's however a question why you want to change the connection string at runtime. The reason I ask this is: is it for database selection at runtime (user opens a client, selects the db to work with from a drop down box, and your app connects) or is it for selecting a userid/password at runtime?
You can alter the dbutils.template for example to use this in selfservicing: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=167
This sets a static property in dbutils which is then used in all the code. What I meant with my question was: if you're switching databases at runtime, it can be that schema's are different so code will not work. Adapter solves this as it keeps 1 store for persistence information per db you connect to (oracle and sqlserver for example). You can also use just 1 generated project and pass a different connection string to the DataAccessAdapter constructor.
To alter the dbutils template: (I use sqlserver and C# as an example here)
- create a copy of dbUtils.template in drivers\SqlServer\Templates\C# and call it for example dbUtilsDynConStr.template
- create a copy of CSharpTemplateSet.config in drivers\SqlServer\Templates and call it for example CSharpTemplateSetCustom.config
- open CSharpTemplateSetCustom.config in a texteditor, it's XML
- change the name tag value so you will recognize it in the generator config window
- in CSharpTemplateSetCustom.config alter the filename in the binding of SD_DbUtilsTemplate to dbUtilsDynConStr.template. Save CSharpTemplateSetCustom.config.
- open dbUtilsDynConStr.template in a texteditor. Add the static property as stated in the thread above. Save the template file.
- in LLBLGen Pro you can now select your own template set when you press F7. When you generate code now using teh selfservicing configurations (Two class scenario for example) you'll get a dbUtils.cs class which contains the additions you made to the template.
Using the static property solution with SelfServicing has a disadvantage: all calls done are using that connection string. So if you want to switch on a per-call basis you have to use Adapter.
You can switch from selfservicing to adapter without much effort (except you can't use lazy loading with adapter). Selfservicing is easier to learn and the problems most people have is with formulating predicate filters, which is the same for adapter or selfservicing (adapter uses a combined Relationcollection - predicate collection object, but that's it)