I've encountered an issue with the DeleteAll function, whereby a doing a Join against another IQueryable object that has a Take(x) operator declared, ignores the Take restriction, so instead of only the Top x records being deleted everything matching the Join is removed. For instance -
var entities = (from c in ctx.Entities select c).Take(5).AsQueryable();
var toDelete = ctx.Tags.Join(entities,
tag => tag.EntityId,
entity => entity.EntityId,
(tag, entity) => tag)
This does a join on all tags and entities rather than only the top 5 entities.
I can't see any documentation to get around this problem, which I'm assuming is a bug, rather than expected behaviour.
To workaround this I was wondering if it is possible to retrieve the commandtext (including parameters) that will be executed for an IQueryable object instead?
This would allow me to dynamically generate a sql statement at runtime to do a bulk delete instead.
Any help much appreciated.