Acessing Local and Network Database

Posts   
 
    
saravana
User
Posts: 63
Joined: 11-Nov-2010
# Posted on: 15-Nov-2011 15:25:50   

I have an WPF application with LLBLGen DAL(Self servicing) as DLL as Data Access Layer. We are using Oracle 11g as database. The new requirement is that the application will also able to connect to local oracle database(standard edition) which is to be installed with all the user machines (if the network is not available). The structure of both local and central database will be same. But we are using the Oracle sequnce numbers for Primary key fields. So is it possible to sync both the database?

if it is not possible we can design few methods which will upload the newly created records from the local database to the central database. In this case how shall I access both database in my application?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Nov-2011 20:05:14   

To access both local and remote DBs you could simple use the DataAccessAdapter ctor that receives a connection string. Then you can keep both local and remote connection strings to be used accordingly.

var connectionStrToUse = FigureOutTheCnnStrToUse();
using (var adapter = new DataAccessAdapter(conectionStrToUse))
{
     ...
}

And for the synchronization, well I don't know, it may be complex or very complex. You should consider the design and the type of actions that will be replicated. But that escapes from the LLBLGen scope, so you should find out there. http://stackoverflow.com/questions/1420688/how-do-i-synchronize-two-oracle-databases http://www.devart.com/blogs/dbforge/index.php/ten-ways-to-synchronize-oracle-table-data.html

David Elizondo | LLBLGen Support Team
saravana
User
Posts: 63
Joined: 11-Nov-2010
# Posted on: 16-Nov-2011 08:28:50   

Hi Daelmo,

Did you mean I can use the below code to access entities from both the database (eventhough the current DAL is selfservicing) ?



var localConnection = GetLocalCnnStr();
EmployeeCollection localEntityCollection = new EmployeeCollection();
using (var adapter = new DataAccessAdapter(localConnection ))
{
    localEntityCollection = localEntityCollection.GetMulti(null);   
}

var centralConnection = GetCentralCnnStr();
EmployeeCollection centralEntityCollection = new EmployeeCollection();
using (var adapter = new DataAccessAdapter(centralConnection ))
{
    centralEntityCollection = centralEntityCollection.GetMulti(null);   
}


Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 16-Nov-2011 09:03:37   

No he meant you should use Adapter template. But I think this is not necessary, since you won't be accessing both databases at the same time.

In SelfServicing, the connection string can be changed at runtime, using the following:

CommonDaoBase.ActualConnectionString = "Datasource=myserver;....";
saravana
User
Posts: 63
Joined: 11-Nov-2010
# Posted on: 06-Dec-2011 07:41:10   

Hi Walaa,

With regard to access both local and Network database, I need to connect to both the database simultaneously to sync the data from local database to cental and to replicate the central data to local database. So I think I might need to switch to Adapter model. I have gone through the following post regrading this:

http://llblgen.com/tinyforum/Messages.aspx?ThreadID=10784&HighLight=1

But in my case we have completed the BL code for 80% of our actual code. So I cannot change it(BL code) to Adapter based DAL now. What my plan is to create an adapter DAL and create a new sub project in BL solution for database Replication and Sync feature alone. Refer the adapter DAL in the new BL project. I hope the entity names generated in adapter DAL is same as selfserviving DAL(?).

Is there is performance 0ver head if I use both DAL (selfservicing and adapter) DLLs in my UI/BL project?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 06-Dec-2011 09:08:40   

Is there is performance 0ver head if I use both DAL (selfservicing and adapter) DLLs in my UI/BL project?

No.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 06-Dec-2011 09:44:12   

To be clear, you can't save a selfservicing entity with an adapter. But if you keep these separate, it's ok. I strongly recommend to stick with 1 template group though, as your code otherwise will become harder to maintain, as it's using 2 different systems and it might be unclear which code uses which system (selfservicing or adapter). So make absolutely sure they're separated in your code.

Frans Bouma | Lead developer LLBLGen Pro