Dynamic tablename

Posts   
 
    
ekcd
User
Posts: 5
Joined: 04-Oct-2010
# Posted on: 05-Oct-2010 09:34:47   

Dear Team,

I am using DataAccessAdapter and I am looking for a solution to change the tablename dynamically.

I tried to do this:

'In there override the GetFieldPersistenceInfo* methods and call the base class' version first. In these overrides, you can then manipulate the table names. It's up to you how you determine when to change which name into which name'

But unfortunately I was not sucessfull. Do you have an example where I can see what to do ?

Up to now I have realized a huge erp solution and for all the tables I use your orm. Accept one table. Because for this table, the name depends on the company number ( 1-99 ). A factoring program create this table at programstart and at the end of the program the table will be renamed. It can happen, that this program is running in serveral companies at the same time. So I need a solution to change the tablename dynamically.

Greetings from Germany

Werner

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Oct-2010 10:11:59   

IMHO, it's not a good practice to store or use information in the schema.

Anyway, if you generate the code against a development schema where the table had the name "company", then at runtime/deployment time you create that table with a different name.

The easiest thing I can think of, is let the code that create that table at runtime, to also create a view called "company" on that table.

That way the generated code will always work on the view regardeless on the underneath table.

ekcd
User
Posts: 5
Joined: 04-Oct-2010
# Posted on: 05-Oct-2010 10:46:07   

Hi Walaa,

thank's for your answer. For the moment it's not possible to change this logic. Also a solution with views is not practicable. If you don't have an example for me , thank you for your help.

Greetings from Germany

Werner

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Oct-2010 15:36:20   

I tried to do this:

'In there override the GetFieldPersistenceInfo* methods and call the base class' version first. In these overrides, you can then manipulate the table names. It's up to you how you determine when to change which name into which name'

But unfortunately I was not sucessfull. Do you have an example where I can see what to do ?

Please post the ode you have tried, and explain what "was not successful" means in details.

(Edit)

Btw, which version of LLBLGen Pro are you using?

And here is a sample code: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7338&StartAtMessage=25&#56867

Thanks.

ekcd
User
Posts: 5
Joined: 04-Oct-2010
# Posted on: 06-Oct-2010 09:11:07   

Hi Walaa,

thank you for your example. I checked the code and now I saw my errors in my code. I changed it and now it works fine.

Thanks again for your help.

Greetings from Germany

smile Werner

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Oct-2010 11:50:25   

You are mostly welcomed.

Greetings from LLBLGen Pro Support Team simple_smile