Exemplo n.º 1
0
        /// <summary>
        /// Gets entities from the database, filtered using a WHERE clause.
        /// </summary>
        /// <param name="whereClause">A string containing the WHERE clause's predicate</param>
        /// <param name="param">Parameters to be passed to the WHERE clause</param>
        public IEnumerable <TEntity> Find(string whereClause, object param = null)
        {
            var sql        = _queryGenerator.Find(Table, SelectFields, whereClause);
            var connection = GetConnection();

            IEnumerable <TEntity> entities;

            try {
                entities = connection.Query <TEntity>(sql, param);
            }
            finally {
                if (!_useProvidedConnection)
                {
                    connection.Dispose();
                }
            }

            return(entities ?? new List <TEntity>());
        }