How to prevent Entity from syncing with persistent storage?

Posts   
 
    
hagervall
User
Posts: 3
Joined: 22-Nov-2011
# Posted on: 22-Nov-2011 10:12:22   

Hi!

I'm writing an application which creates large amounts of new entities, and I'm wondering if there is any way I can control the syncing behavior when I assign a value to the PK field?

ExampleEntity ee = new ExampleEntity();
ee.ID = "Some Unique Name"; // <-- This triggers a lookup/fetch

This wouldn't be a problem if it weren't for the fact that this has to be done about 10000 times per minute - all those lookups are killing performance.

What I'd like is some way to create all new entities without triggering lookups and then save them all in one go.

I'm using LLBLGen Pro v3.1 (Trial) and MSSQL 2008.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Nov-2011 10:33:01   

Not sure I understand you 100%.

ee.ID = "Some Unique Name"; // <-- This triggers a lookup/fetch

The ID gets a new Unique value, right? Do you get this value from the database? If yes, I wonder why they are saved there. Why not using an Identity field, or a UniqueIdentifier (GUID) field, or even set it toa unique GUID in code.

hagervall
User
Posts: 3
Joined: 22-Nov-2011
# Posted on: 22-Nov-2011 14:50:41   

Walaa wrote:

Not sure I understand you 100%.

ee.ID = "Some Unique Name"; // <-- This triggers a lookup/fetch

The ID gets a new Unique value, right? Do you get this value from the database? If yes, I wonder why they are saved there. Why not using an Identity field, or a UniqueIdentifier (GUID) field, or even set it toa unique GUID in code.

Ok, perhaps I should clarify:

The entity in question is a model of external data, and the PK is a hash of the entity fields that uniquely identifies the entity. It is also a "leaf node" in an larger schema. When I receive new data, I need to either:

  • Create a new entity
  • Update an existing entity
  • Delete an existing entity At first I tried using autoincrement PK:s, and called SaveMulti(true) on the root entity collection, and spent roughly 10 seconds waiting for less than 3000 rows to be written to the database.

Using computed PK:s I have been able to work around the slowness of SaveMulti(..) using SQLBulkCopy(), however, creating new entities is still a bottleneck.

Update and Delete I can do without problems. (Performance-wise)

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Nov-2011 18:55:38   

hagervall wrote:

ExampleEntity ee = new ExampleEntity();
ee.ID = "Some Unique Name"; // <-- This triggers a lookup/fetch

I'm confused too. That line won't trigger a fetch. Maybe if you show us the complete code snippet and what exactly are you trying to achieve/avoid.

David Elizondo | LLBLGen Support Team
hagervall
User
Posts: 3
Joined: 22-Nov-2011
# Posted on: 24-Nov-2011 08:52:03   

Never mind, it turns out that I had a watch in the debugger which triggered a fetch when I hit a breakpoint right around the line where I assigned the PK field.

Sorry to have wasted your time.