| layout | default | |||
|---|---|---|---|---|
| sidebar | operations | |||
| title | MinAll | |||
| permalink | /operation/minall | |||
| tags |
|
|||
| parent | OPERATIONS |
This method is used to compute the minimum value of the target field.
Below is the sample code that returns the minimum value of the column Value from a [dbo].[Sales] table.
using (var connection = new SqlConnection(connectionString))
{
var expenses = connection.MinAll<Sales>(e => e.Value);
}You can also target a specific table by passing the literal table and field name like below.
using (var connection = new SqlConnection(connectionString))
{
var expenses = connection.MinAll("[dbo].[Sales]",
Field.From("Value"));
}To pass a hint, simply write the table-hints and pass it in the hints argument.
using (var connection = new SqlConnection(connectionString))
{
var expenses = connection.MinAll<Sales>(e => e.Value,
hints: "WITH (NOLOCK)");
}Or, you can use the SqlServerTableHints class.
using (var connection = new SqlConnection(connectionString))
{
var expenses = connection.MinAll<Sales>(e => e.Value,
hints: SqlServerTableHints.NoLock);
}