Capacity property

Posts   
 
    
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 15-Sep-2009 22:56:20   

As I understand Capacity property its get / set initial capacity of the entity collection

like my table has** 2 records after fetching found Capacity property has 4**

i think it should be 2 not 4 is there any miss understand ??

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 16-Sep-2009 06:22:08   

Can you please elaborate more? What is the concern? ... and more relevant info.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 16-Sep-2009 10:22:32   

These capacities are all removed in a later build. Please check the latest build of the runtime libs.

Frans Bouma | Lead developer LLBLGen Pro
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 16-Sep-2009 12:52:33   

Otis wrote:

These capacities are all removed in a later build. Please check the latest build of the runtime libs.

I downloaded last build (26-August-2009) release (10-Sep-2009) and still capacity property exists

public int Capacity { set; get; } Member of SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore<T>

Summary: Gets / sets the initial capacity of the entity collection.

SD.LLBLGen.Pro.ORMSupportClasses.NET20 file version 2.6.9.903

daelmo wrote:

Can you please elaborate more? What is the concern? ... and more relevant info.

in more detail


             EntityCollection<CustomerEntity> customerEc= new EntityCollection<CustomerEntity>(); 
             //Fetching All records from customer table it contains only 2 records
            BL.CustomerManager.Fill(customerEc, null);
            
            // Capacity property retuns 4
            int cap = ec.Capacity;

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 16-Sep-2009 13:08:40   

the initial capacity is not set anymore, it's therefore the default of List<T>, which apparently is 4. See EntityCollectionBase2 CTor's call to InitClass, which passes 0, which ends up in CollectionCore<T>'s InitCoreClass, which initializes the internal set of elements to List<T> which capacity is returned by Capacity.

So the capacity isn't really useful other than making sure there's room in the collection before it has to resize its internal array (inside List<T>).

Frans Bouma | Lead developer LLBLGen Pro