Instantiate collection without new EntityFactory

Posts   
 
    
Meteor
User
Posts: 67
Joined: 06-Apr-2007
# Posted on: 13-Feb-2009 14:26:58   

Out of interest, what's the difference between the following two lines of code:

EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>();

and

EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>(new CustomerEntityFactory());

I've seen both forms used, but never understood the difference.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39589
Joined: 17-Aug-2003
# Posted on: 13-Feb-2009 18:41:28   

Meteor wrote:

Out of interest, what's the difference between the following two lines of code:

EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>();

and

EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>(new CustomerEntityFactory());

I've seen both forms used, but never understood the difference.

The first uses a trick to obtain the factory from the generic type. The second uses the factory specified. For nittpickers, the second one is slightly faster, though only by a fraction. The second one also allows you to specify a more specific factory.

Frans Bouma | Lead developer LLBLGen Pro