Switching between Data Models at runtime

Posts   
 
    
Valemus avatar
Valemus
User
Posts: 37
Joined: 09-Jan-2018
# Posted on: 22-Feb-2018 15:53:25   

Hi,

I have a project (model-first) with two Relational Model Data: Sql Server and MsAccess. C#, v5.3, Selfservicing.

I'm trying to achieve the following: at runtime, depending on an option that can be set by the user, the program should fetch the data from the Sql Server Db or from the MsAccess one, without changing the code behind.

However the problem is that I should change the references at design time to switch between the two data models.

I've seen that there is an injection system inside LLBLGen that perhaps can be helpful in this case, but I could't find how. Is there already some documentation about this topic that I am missing? (I bet I'm not the only one doing such a thing).

Thank you!

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Feb-2018 20:40:54   

This won't work with SelfServicing. You need to use the Adapter template set.

Valemus avatar
Valemus
User
Posts: 37
Joined: 09-Jan-2018
# Posted on: 23-Feb-2018 08:51:27   

Walaa wrote:

This won't work with SelfServicing. You need to use the Adapter template set.

Ouch. disappointed

I think I have to find an escamotage if I don't want to rewrite the whole project.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 23-Feb-2018 09:34:45   

Switching between adapter and selfservicing isn't that hard. At first you think this is a lot of work, but if you use linq or queryspec, the amount of code you have to rewrite isn't that much. I ported this forum from selfservicing to adapter in 2 days.

If you have questions regarding how to port things from selfservicing to adapter, just ask. Also, the documentation is organized in such a way that a page for selfservicing has an equivalent for adapter, so you can rather quickly find the same example for adapter.

Frans Bouma | Lead developer LLBLGen Pro
Valemus avatar
Valemus
User
Posts: 37
Joined: 09-Jan-2018
# Posted on: 23-Feb-2018 12:12:00   

Otis wrote:

Switching between adapter and selfservicing isn't that hard. At first you think this is a lot of work, but if you use linq or queryspec, the amount of code you have to rewrite isn't that much. I ported this forum from selfservicing to adapter in 2 days.

Thanks, Otis, you're correct... I've started the conversion and I think in a couple of days I should have done it.

(I'm just sorry for leaving the self-servicing mode, since I love its cleaniness wink )

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 23-Feb-2018 14:32:49   

simple_smile Cleaniness as in: you can rely on lazy loading instead of writing queries? Or the .Save() methods etc. instead of needing to use using(var adapter = ...) { } ?

Frans Bouma | Lead developer LLBLGen Pro