public IList <TSelect> Retrieve <TSelect, TFrom, TWhere>(SelectExpression <TSelect> selectCondition, FromExpression <TFrom> fromCondition, WhereExpression <TWhere> whereCondition, TransactionContext transContext = null) where TSelect : DatabaseEntity, new() where TFrom : DatabaseEntity, new() where TWhere : DatabaseEntity, new() { #region Argument Adjusting if (selectCondition != null) { selectCondition.Select(t => t.Id).Select(t => t.Deleted).Select(t => t.LastTime).Select(t => t.LastUser).Select(t => t.Version); } if (whereCondition == null) { whereCondition = Where <TWhere>(); } whereCondition.And(t => t.Deleted == false).And <TSelect>(ts => ts.Deleted == false).And <TFrom>(tf => tf.Deleted == false); #endregion IList <TSelect> result = null; IDataReader reader = null; DatabaseEntityDef selectDef = _entityDefFactory.GetDef <TSelect>(); try { IDbCommand command = _sqlBuilder.CreateRetrieveCommand(selectCondition, fromCondition, whereCondition); reader = _databaseEngine.ExecuteCommandReader(transContext?.Transaction, selectDef.DatabaseName, command, transContext != null); result = _modelMapper.ToList <TSelect>(reader); } //catch (DbException ex) //{ // throw ex; //} finally { if (reader != null) { reader.Dispose(); } } return(result); }