[
https://issues.apache.org/jira/browse/IGNITE-5298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16098623#comment-16098623
]
Sergey Stronchinskiy commented on IGNITE-5298:
----------------------------------------------
Hi, [~ptupitsyn]
I don't have actual usage statistics but based on top search results for "c#
mock set property value", the main approach for {{Moq}} is using
{{SetupProperty}} or {{SetupGet}} like:
{code}
mockPerson.SetupGet(s => s.OrgId ).Returns(42);
{code}
So I'm not really sure that {{==}} API is that popular and would be that
familiar to many users.
Also I think {{Moq}}'s usecase slightly differs from what {{Ignite}} needs,
cause i guess that {{Moq}} doesn't need to handle expressions with field
combination, like {{person.FullName == person.FirstName + person.LastName}} and
processing filed combinations for {{boolean}} fields (like, for example,
expression {{p.B1 == p.B2 && p.B3 == p.B1 && p.B4}}) can a) introduce some
propensity for errors for API users b) may need more complex handling.
I still think that the best solution to have two API's - easier and cleaner
initializer syntax for "simple cases" and more wordy for the cases when
initializer syntax is no suitable. For the latter one I suggest next
solution(which is similar to what you have suggested originally, but without
"global" {{Set}} method):
The {{UpdateAll}} method's signature:
{code}
public static int UpdateAll<TKey, TValue>(this IQueryable<ICacheEntry<TKey,
TValue>> query,
Expression<Func<IUpdateDescriptor<TValue>, IUpdateDescriptor<TValue>>>
update)
{
throw new NotImplementedException();
}
{code}
The {{IUpdateDescriptor}} service interface:
{code}
public interface IUpdateDescriptor<T>
{
IUpdateDescriptor<T> Set<TProp>(Func<T, TProp> selector, TProp value);
IUpdateDescriptor<T> Set<TProp>(Func<T, TProp> selector, Func<T, TProp>
valueBuilder);
}
{code}
Usage:
{code}
queryable.UpdateAll(d => d.Set(p => p.OrgId, 42)
.Set(p => p.Age, p => p.Age + 42));
{code}
I think despite being a little bit wordy it is intuitive enough, and is similar
to {{Moq}}'s {{Setup}} pattern and [NHibirnate's DML style
batching|http://nhibernate.info/doc/nhibernate-reference/batch.html#batch-direct]
> .NET: DML update via LINQ
> -------------------------
>
> Key: IGNITE-5298
> URL: https://issues.apache.org/jira/browse/IGNITE-5298
> Project: Ignite
> Issue Type: New Feature
> Components: platforms
> Affects Versions: 2.1
> Reporter: Pavel Tupitsyn
> Assignee: Sergey Stronchinskiy
> Labels: .NET, LINQ, important
>
> Bulk update with LINQ:
> {code}
> var persons = ignite.GetCache<int, Person>("persons").AsCacheQueryable();
> int affectedRows = persons.Where(x => x.Key > 10).UpdateAll(x =>
> x.Value.OrgId = 7);
> {code}
> See bulk delete with {{RemoveAll}}, IGNITE-4904.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)