Llblgen v 5.3, nhibernate v4 . CRUD example for firebird DB

Posts   
 
    
alonsoChen
User
Posts: 30
Joined: 27-Nov-2017
# Posted on: 12-Feb-2018 07:35:37   

Is there any example for nhibernate v4 CRUD? Is there any connection string can set in code instead of using configuration file through nhibernate v4 , llblgen v5.3 and how?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 12-Feb-2018 16:28:00   

alonsoChen wrote:

Is there any example for nhibernate v4 CRUD?

No sorry. The generated code is simply giving you a default setup of NHibernate and mappings, how to use NHibernate after that is up to the NHibernate documentation and tutorials. The generated code is not different than what you'd write yourself and how you'd use nhibernate with hand-written mappings/session manager classes.

Is there any connection string can set in code instead of using configuration file through nhibernate v4 , llblgen v5.3 and how?

No. In that case you should create your own SessionManager class which you could base on the one that's generated and where you pass in the connection string in the constructor instead of reading it from the config file as the generated class does.

The generated class is just a basic one, you might want a more advanced one or a different one. If you don't want the code generator to generate the SessionManager class anymore, simply remove the task definition from the preset, using the PresetViewer in the designer, open the preset you're using and remove the SessionManager task from it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 13-Feb-2018 10:47:52   

I looked at providing a connectionstring in code to the Sessionmanager class, but as it's a static class using a static constructor, that's not possible: the connection string can't be passed to the static constructor so to fix this the sessionmanager class has to be rewritten to something non-static.

To overcome this issue, you can rewrite the sessionmanager class based on the generated code in another class and create factory method there with a static variable. This isn't ideal though.

Frans Bouma | Lead developer LLBLGen Pro