/// Translates re-linq's QueryModel object to a PostgreSQL query, executes it and returns the result. /// /// Returns: A collection of items being the result of the query. public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel) { _connection.Open(); var psqlCommand = PsqlGeneratingQueryModelVisitor.GeneratePsqlQuery(queryModel); var result = typeof(T).IsAnonymous() ? _connection.QueryAnonymous <T>(psqlCommand.Statement, psqlCommand.Parameters) : _connection.Query <T>(psqlCommand.Statement, psqlCommand.Parameters); _connection.Close(); return(result); }
public IEnumerable <T> ExecuteCollection <T>(QueryModel queryModel) { var psqlCommand = PsqlGeneratingQueryModelVisitor.GeneratePsqlQuery(queryModel, _table); var pgCommand = new PgSqlCommand(); pgCommand.Command = psqlCommand.Statement; pgCommand.Parameters.AddRange(psqlCommand.Parameters); Debug.WriteLine(pgCommand.CommandAsPlainText()); return(new DbExecuter(_table.GetConnectionString()).ExecuteReader <T>(pgCommand)); }