uow.entity.detached.where()

2
Voted

Whenever I write a lightspeedcode that has to traverse a lot of records (1 million+) and I use normal linq code I run out of memory. This happens because lightspeed caches the entities. My workaround is to detach each entitity as it is retrieved within the processing loop.

I know there are alternatives like writing a special query and map columns to propties myself. But that means more and ugly code imho.

I'd suggest a new codeword .Detached. like .WithIndexHint. and such which makes Ligthspeed;

  • Not cache the entity
  • Not keep the entity attached to the unitofwork
  • Skip doing anything fancy that is not needed if you only want to walk through the result set once and not re-use anything.

Not only will this fix the memory ballooning, it might also speed things up considerably. All while being able to keep the code small, neat and readable.

Status: New