/// <summary> /// Gets the single item. /// </summary> /// <param name="filters">The filters.</param> /// <returns>A value of type T.</returns> public T GetSingleItem(params SqlFilter[] filters) { if ((filters == null) || (filters.Length == 0)) { throw new ArgumentNullException("filters"); } if (Connection == null) { throw new InvalidOperationException("must set connection before calling GetSingleItem()"); } DbCommand command = PrepCommandForSelect(string.Empty, FillMethod.FilterArray, filters); SqlDialect.OptimizeSelectSingleCommand(command); return(GetSingleItem(command)); }
/// <summary> /// Gets the single item. /// </summary> /// <param name="filter">The filter.</param> /// <param name="parameters">The parameters.</param> /// <returns>A value of type T.</returns> public T GetSingleItem(string filter, params object[] parameters) { if (string.IsNullOrEmpty(filter)) { throw new ArgumentNullException("filter"); } if (Connection == null) { throw new InvalidOperationException("must set connection before calling GetSingleItem()"); } DbCommand command = PrepCommandForSelect(filter, FillMethod.FilterText, parameters); SqlDialect.OptimizeSelectSingleCommand(command); return(GetSingleItem(command)); }
public T GetSingleItem(Expression <Func <T, bool> > filterExpression) { if (Connection == null) { throw new InvalidOperationException("must set connection before calling GetSingleItem()"); } var parser = new WhereExpressionParser <T>(DataMap, SqlDialect) { UseQuotedIdentifier = CommandBuilder.UseQuotedIdentifier }; var result = parser.Parse(filterExpression); DbCommand command = PrepCommandForSelect(result.SqlText, FillMethod.FilterText, result.Parameters); SqlDialect.OptimizeSelectSingleCommand(command); return(GetSingleItem(command)); }