/// <summary> /// Execute Quary /// </summary> /// <param name="expression"></param> /// <returns></returns> public object Execute(Expression expression) { var _expression = new LightDataLinqToNoSql(expression.Type.GetActualType(), this); _expression.Translate(expression); return(_dbSchema.Select(expression.Type, _expression.Quary)); }
/// <summary> /// Execute the search Command /// </summary> /// <returns></returns> public async Task <List <T> > ExecuteAsync() { if (_executed) { return(this.ToList <T>()); } else { var result = new List <T>(); _expression.DataBaseTypes = _repository.DataBaseTypes; foreach (var exp in _matches) { _expression.Translate(exp); } ParsedLinqToSql = _expression.Quary; if (!_partExecuted) { result.AddRange(await _repository.SelectAsync <T>(ParsedLinqToSql)); } if (_childrenToLoad.Any() || _landholderOnlyFirstLevel.HasValue) { foreach (var item in result) { if (_childrenToLoad.Any()) { await _repository.LoadChildrenAsync(item, false, _ignoreActions, _childrenToLoad.ToArray()); } else { await _repository.LoadChildrenAsync(item, _landholderOnlyFirstLevel.Value, null, _ignoreActions); } } } _executed = true; this.AddRange(result); } return(this.ToList <T>()); }
public List <T> Execute() { if (_executed) { return(this.ToList <T>()); } else { _expression.IsSqlLight = _repository.GetDataBaseType() == Helper.DataBaseTypes.Sqllight; foreach (var exp in _matches) { _expression.Translate(exp); } ParsedLinqToSql = _expression.Quary; if (!_partExecuted) { this.AddRange(!string.IsNullOrEmpty(_expression.Quary) ? _repository.Where <T>(_expression) : _repository.GetAbstractAll <T>()); } if (_childrenToLoad.Any() || _loadcholdrenOnlyFirstLevel.HasValue) { foreach (var item in this) { if (_childrenToLoad.Any()) { _repository.LoadChildren(item, false, _ignoreActions, _childrenToLoad.ToArray()); } else { _repository.LoadChildren(item, _loadcholdrenOnlyFirstLevel.Value, _ignoreActions); } } } _executed = true; } return(this.ToList <T>()); }
/// <summary> /// Execute generic quary /// </summary> /// <typeparam name="TResult"></typeparam> /// <param name="expression"></param> /// <returns></returns> public TResult Execute <TResult>(Expression expression) { var isEnumerable = (typeof(TResult).Name == "IEnumerable`1"); var _expression = new LightDataLinqToNoSql(typeof(TResult).GetActualType(), this); _expression.Translate(expression); if (!isEnumerable) { return(Select <TResult>(_expression.Quary).First()); } else { return((TResult)_dbSchema.Select(expression.Type, _expression.Quary)); } }