ravendb / samples-yabt

"Yet Another Bug Tracker" solution sample for RavenDB and .NET with Angular UI
https://yabt.ravendb.net
MIT License
107 stars 22 forks source link

Make patch requests strongly typed #34

Closed AKlaus closed 2 years ago

AKlaus commented 3 years ago

Rewrite patch requests in a more strongly typed way (as it was suggested in ravendb/ravendb/issues/12650).

Example:

var index = GetIndexQuery(session.Query<PrimarySkills.Result, PrimarySkills>()
                                 .Where(result => result.SkillId == 1));

index.Query += @" update { 
      for (var i = 0; i < this.Skills.length; i++) {
          this.Skills[i].IsPrimary = false
      }
}";
var operation = store.Operations.Send(new PatchByQueryOperation(index));

static IndexQuery GetIndexQuery<T>(IQueryable<T> queryable)
{
      var inspector = (IRavenQueryInspector)queryable;
      return inspector.GetIndexQuery(isAsync: false);
}