Click or drag to resize
SqlExpressionEGetSelectScalarSqlT Method
Creates a scalar SELECT SQL based on the passed parameters.

Namespace: LiteRepository
Assembly: LiteRepository (in LiteRepository.dll) Version: 2.0.4
Syntax
C#
public string GetSelectScalarSql<T>(
	Expression<Func<IEnumerable<E>, T>> expression,
	Expression<Func<E, bool>> where = null,
	Object param = null
)

Parameters

expression
Type: System.Linq.ExpressionsExpressionFuncIEnumerableE, T
Scalar expression
where (Optional)
Type: System.Linq.ExpressionsExpressionFuncE, Boolean
Where expression. You can use members of E or param. Other values will be evaluated.
param (Optional)
Type: SystemObject
Query parameters

Type Parameters

T
Result type

Return Value

Type: String
A string with a select scalar query.
Examples

You need to pass expression for retrive scalar data form database:

C#
var sql = GetSelectScalarSql{T}(l => l.Average(e => e.Price));
// select avg(Price) from Table;

T is the return type for expression. Where expression used like in GetSelectSql.

See Also