Working Disconnected from the database

Posts   
 
    
timd
User
Posts: 5
Joined: 13-Mar-2008
# Posted on: 18-Mar-2008 18:29:41   

Is there any way to use a Self-Servicing implementation that works in disconnected mode. We are writing tests and will be using a "mock" provider when the database is not complete or unavailable. But everytime we access a collection on an object to ADD a new instance to the collection, it hits the Db and blows up.

This is not a UI but a backend Business Layer we are building.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 18-Mar-2008 20:10:04   

Hi, how exactly are you implementing this "mock" provider, please provide more details of your project and if possible a small test solution so we can help you better.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 19-Mar-2008 09:42:30   

Instead of: myCustomer.Orders.Add(myOrder); which triggers lazy loading you can do: myOrder.Customer = myCustomer;

which doesn't trigger lazy loading but will add myOrder to myCustomer.Orders for you simple_smile

Frans Bouma | Lead developer LLBLGen Pro
timd
User
Posts: 5
Joined: 13-Mar-2008
# Posted on: 19-Mar-2008 13:07:14   

OK will try this and see what it does for us.

So there is no way to shut off the DB connection and work disconnected?

The Mock reads data from XML files, creates instances of entities and returns populated class instances to the business layer. The Provider layer allows us to switch out the DB with XML files easily for testing specific scenarios without creating bogus data in our test DB.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Mar-2008 16:13:33   

Either avoid lazy loading, or better use the Adapter model to be sure that nothing connects to the database as long as you are not using a DataAccessAdapter instance.