Reference > Functions > Mathematical

Tan

  • 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022

Tan (Tangent) Mathematical Function

Use the Tan function to return the tangent of the specified expression.

Syntax

db.fx.Tan({expression})

Arguments

expression
The value to use in the tangent calculation.

Returns

float

Examples

Select Statement

Select the tangent of a product's weight (which is nullable in the database).

float? result = db.SelectOne(
        db.fx.Tan(dbo.Product.Weight)
    )
    .From(dbo.Product)
    .Execute();

Where Clause

Select the tangent of a product's depth (which is nullable in the database).

float? result = db.SelectOne(
        db.fx.Tan(dbo.Product.Depth)
    )
    .From(dbo.Product)
    .Execute();

Order By Clause

Select and order by the tangent of a product's depth.

IEnumerable<Product> result = db.SelectMany<Product>()
    .From(dbo.Product)
    .OrderBy(db.fx.Tan(dbo.Product.Depth).Desc())
    .Execute();

Group By Clause

Select product details grouped by product category and the tangent of the product's depth.

IEnumerable<dynamic> results = db.SelectMany(
        dbo.Product.ProductCategoryType,
        db.fx.Tan(dbo.Product.Depth).As("calculated_value")
    )
    .From(dbo.Product)
    .GroupBy(
        dbo.Product.ProductCategoryType,
        db.fx.Tan(dbo.Product.Depth)
    )
    .Execute();

Having Clause

Select the ids of all products, grouped by product category type having a tangent of the product's height greater than the product's width.

IEnumerable<ProductCategoryType?> results = db.SelectMany(
        dbo.Product.ProductCategoryType
    )
    .From(dbo.Product)
    .GroupBy(
        dbo.Product.ProductCategoryType,
        db.fx.Tan(dbo.Product.Height),
        dbo.Product.Width
    )
    .Having(
        db.fx.Tan(dbo.Product.Height) > dbo.Product.Width
    )
    .Execute();
Previous
Square

© 2024 dbExpression. All rights reserved.