DeleteEntitiesDirectly and UpdateEntitiesDirectly with LINQ expressions

Posts   
 
    
ioan
User
Posts: 12
Joined: 20-Nov-2018
# Posted on: 26-Feb-2019 10:35:39   

I tried to find an easy way of deleting/updating entities directly in LLBLGen, and the methods DeleteEntitiesDirectly/UpdateEntitiesDirectly seem the perfect match for what I need. However, it would be way easier to use something like:


adapter.DeleteEntitiesDirectly<Customer>(c => c.Name.StartsWith("John"));

instead of manually creating the predicate bucket. Did I miss something or these LINQ expressions are not supported currently?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Feb-2019 06:29:55   

This is not available. I'll pass your request to the developing team.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Feb-2019 10:36:31   

Parsing expression trees is pretty complicated, as there's no end to what you can add there: you can specify a complicated expression there spanning a lot of entities. Parsing expression trees in our linq provider is a complicated process which isn't re-usable here, hence we don't offer that.

It's not all bad tho. The QuerySpec extension methods make specifying the predicates not that complicated.

adapter.DeleteEntitiesDirectly(new RelationPredicateBucket(CustomerFields.Name.Equal("John")));

If you hate the bucket ctor call, you can add an extension method, e.g. ToBucket(IPredicate) :

public static IRelationPredicateBucket(this IPredicate toWrap)
{
    return new RelationPredicateBucket(toWrap);
}

Which then leads to:

adapter.DeleteEntitiesDirectly(CustomerFields.Name.Equal("John").ToBucket());

Frans Bouma | Lead developer LLBLGen Pro
ioan
User
Posts: 12
Joined: 20-Nov-2018
# Posted on: 27-Feb-2019 16:21:56   

@Otis: thanks for the clarification. It would have been very nice to have a syntax not so dependent on LLBLGen, like LINQ is, but I understand the difficulties. At least I know what I can do simple_smile .