private QueryTask CreateFetchVersionTask(Key key) { var type = key.TypeInfo; var provider = type.Indexes.PrimaryIndex.GetQuery().Seek(key.Value); var execProvider = Session.Compile(provider); return(new QueryTask(execProvider, Session.GetLifetimeToken(), null)); }
/// <inheritdoc/> public void Lock(LockMode lockMode, LockBehavior lockBehavior) { using (new ParameterContext().Activate()) { keyParameter.Value = Key.Value; object key = new Triplet <TypeInfo, LockMode, LockBehavior>(TypeInfo, lockMode, lockBehavior); Func <object, object> generator = tripletObj => { var triplet = (Triplet <TypeInfo, LockMode, LockBehavior>)tripletObj; IndexInfo index = triplet.First.Indexes.PrimaryIndex; var query = index.GetQuery() .Seek(() => keyParameter.Value) .Lock(() => triplet.Second, () => triplet.Third) .Select(); return(Session.Compile(query)); }; var source = (ExecutableProvider)Session.StorageNode.InternalQueryCache.GetOrAdd(key, generator); var recordSet = source.GetRecordSet(Session); recordSet.FirstOrDefault(); } }
/// <inheritdoc/> public void Lock(LockMode lockMode, LockBehavior lockBehavior) { var parameterContext = new ParameterContext(); parameterContext.SetValue(keyParameter, Key.Value); object key = new Triplet <TypeInfo, LockMode, LockBehavior>(TypeInfo, lockMode, lockBehavior); Func <object, object> generator = tripletObj => { var triplet = (Triplet <TypeInfo, LockMode, LockBehavior>)tripletObj; var index = triplet.First.Indexes.PrimaryIndex; var query = index.GetQuery() .Seek(context => context.GetValue(keyParameter)) .Lock(() => triplet.Second, () => triplet.Third) .Select(); return(Session.Compile(query)); }; var source = (ExecutableProvider)Session.StorageNode.InternalQueryCache.GetOrAdd(key, generator); using var recordSetReader = source.GetRecordSetReader(Session, parameterContext); recordSetReader.MoveNext(); }