private async Task <T> GetValueSyncOrAsync(bool sync, CancellationToken token = default(CancellationToken)) { T result; if (!_deferred) { CreateCriteriaOrFutures(); } if (_mainFuture != null) { if (_childFutures != null) { foreach (var cq in _childFutures) //we need to force execution: oracle client doesn't support multiple queries (for now) { if (sync) { cq.GetEnumerable(); } else { await cq.GetEnumerableAsync(token); } } } if (sync) { result = _mainFuture.Value; } else { result = await _mainFuture.GetValueAsync(token); } } else { if (sync) { result = _mainCriteria.UniqueResult <T>(); } else { result = await _mainCriteria.UniqueResultAsync <T>(token); } } if (_childNodesInfo != null) { NHUnitHelper.VisitNodes(result, _session, _childNodesInfo); } if (_unproxy) { return(NHUnitHelper.Unproxy(result, _session)); } return(result); }
public async Task <T> GetValueSyncOrAsync(bool sync, CancellationToken token = default(CancellationToken)) { T result; if (_deferred) { if (sync) { result = _mainFuture.GetEnumerable().FirstOrDefault(); } else { var tmp = await _mainFuture.GetEnumerableAsync(token); result = tmp.FirstOrDefault(); } } else { if (sync) { result = await _query.FirstOrDefaultAsync(token); } else { result = _query.FirstOrDefault(); } } if (result != null) { if (_childNodesInfo != null) { NHUnitHelper.VisitNodes(result, _session, _childNodesInfo); } if (_unproxy) { result = NHUnitHelper.Unproxy(result, _session); } } return(result); }
public T Unproxy <T>(T obj) { return(NHUnitHelper.Unproxy(obj, Session)); }
public IEntityListWrapper <T> Include(params Expression <Func <T, object> >[] includeChildNodes) { _childNodesInfo = NHUnitHelper.GetExpressionTreeInfo <T>(includeChildNodes, _childNodesInfo ?? new EntityNodeInfo(), true); return(this); }
public ISingleEntityWrapper <T> Include(params Expression <Func <T, object> >[] includeChildNodes) { CheckDeferred(); _childNodesInfo = NHUnitHelper.GetExpressionTreeInfo <T>(includeChildNodes, _childNodesInfo ?? new EntityNodeInfo(), true); return(this); }