[ 
https://issues.apache.org/jira/browse/IGNITE-4904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16024830#comment-16024830
 ] 

Pavel Tupitsyn edited comment on IGNITE-4904 at 5/25/17 3:31 PM:
-----------------------------------------------------------------

Turns out {{DELETE FROM}} with joins is not supported by H2: 
http://www.h2database.com/html/grammar.html#delete
The workaround is to use subquery ({{Contains}} in LINQ).

Examples of supported queries:
{code}
var persons = ignite.GetCache<int, Person>("persons").AsCacheQueryable();

persons.Where(x => x.Key > 10).RemoveAll();
persons.RemoveAll(x => x.Key > 10);  // Exactly the same SQL as above
persons.Take(3).RemoveAll();

// Join workaround:
var orgs = ignite.GetCache<int, Organization>("orgs").AsCacheQueryable();
var orgIds = orgs.Where(x => x.Value.Name == "foo").Select(x => x.Key);
persons.Where(x => orgIds.Contains(x.Value.OrgId)).RemoveAll();  // Generates 
_key IN (select ...)
{code}


was (Author: ptupitsyn):
Turns out {{DELETE FROM}} with joins is not supported by H2: 
http://www.h2database.com/html/grammar.html#delete
The workaround is to use subquery ({{Contains}} in LINQ).

Examples of supported queries:
{code}
var persons = ignite.GetCache<int, Person>("persons").AsCacheQueryable();

persons.Where(x => x.Key > 10).RemoveAll();
persons.RemoveAll(x => x.Key > 10);  // Exactly the same SQL as above

// Join workaround:
var orgs = ignite.GetCache<int, Organization>("orgs").AsCacheQueryable();
var orgIds = orgs.Where(x => x.Value.Name == "foo").Select(x => x.Key);
persons.Where(x => orgIds.Contains(x.Value.OrgId)).RemoveAll();  // Generates 
_key IN (select ...)

{code}

> .NET: DML via LINQ
> ------------------
>
>                 Key: IGNITE-4904
>                 URL: https://issues.apache.org/jira/browse/IGNITE-4904
>             Project: Ignite
>          Issue Type: New Feature
>          Components: platforms
>    Affects Versions: 1.9
>            Reporter: Pavel Tupitsyn
>            Assignee: Pavel Tupitsyn
>              Labels: .NET, LINQ
>             Fix For: 2.1
>
>
> Perform bulk update operations via LINQ: {{UPDATE WHERE}}, {{DELETE WHERE}}. 
> Insert can already be done on object level with {{ICache.PutAll}}.
> 1) {{DELETE WHERE}}. This is quite simple. We can provide an extension method 
> like this:
> {code}
> public static int DeleteAll<K, V>(this ICache<K, V> cache, 
> IQueryable<ICacheEntry<K, V>> items);
> {code}
> 2) {{UPDATE WHERE}}. This is tricky, because LINQ only works with expression 
> trees, and multi-line methods are not supported. We should come up with a way 
> to provide a list of columns and values, something like
> {code}
> public static int UpdateAll<K, V>(this ICache<K, V> cache, 
> IQueryable<ICacheEntry<K, V>> items, params UpdateAction[] actions);
> {code}
> where UpdateAction can consist of a MemberExpression and a value for that 
> member.
> We should probably do delete as a separate task first.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to