Reference > Functions > Mathematical
ACos
- 2005
- 2008
- 2012
- 2014
- 2016
- 2017
- 2019
- 2022
- 2005, 2008, 2012, 2014, 2016, 2017, 2019, 2022
ACos (Arccosine) Mathematical Function
Use the ACos
function to return the arccosine of the specified expression.
Syntax
db.fx.ACos({expression})
Arguments
- expression
- – The value to use in the arccosine calculation. The value of `expression` must be between -1 and 1.
Returns
float
Examples
A where clause has been added to the following examples to ensure successful execution.
Select Statement
Select the arccosine of a product's weight (which is nullable in the database).
float? result = db.SelectOne(
db.fx.ACos(dbo.Product.Weight)
)
.From(dbo.Product)
.Where(dbo.Product.Weight > 0 & dbo.Product.Weight < 1)
.Execute();
Where Clause
Select the arccosine of a product's depth (which is nullable in the database).
float? result = db.SelectOne(
db.fx.ACos(dbo.Product.Depth)
)
.From(dbo.Product)
.Where(dbo.Product.Depth > 0 & dbo.Product.Depth < 1)
.Execute();
Order By Clause
Select and order by the arccosine of a product's depth.
IEnumerable<Product> result = db.SelectMany<Product>()
.From(dbo.Product)
.Where(dbo.Product.Depth > 0 & dbo.Product.Depth < 1)
.OrderBy(db.fx.ACos(dbo.Product.Depth).Desc())
.Execute();
Group By Clause
Select product details grouped by product category and arccosine of the product's depth.
IEnumerable<dynamic> results = db.SelectMany(
dbo.Product.ProductCategoryType,
db.fx.ACos(dbo.Product.Depth).As("calculated_value")
)
.From(dbo.Product)
.Where(dbo.Product.Depth > 0 & dbo.Product.Depth < 1)
.GroupBy(
dbo.Product.ProductCategoryType,
db.fx.ACos(dbo.Product.Depth)
)
.Execute();
Having Clause
Select the ids of all products, grouped by product category type having an arccosine of the product's height greater than 1.
IEnumerable<ProductCategoryType?> results = db.SelectMany(
dbo.Product.ProductCategoryType
)
.From(dbo.Product)
.Where(dbo.Product.Height > 0 & dbo.Product.Height < 1)
.GroupBy(
dbo.Product.ProductCategoryType,
db.fx.ACos(dbo.Product.Height)
)
.Having(
db.fx.ACos(dbo.Product.Height) < .5f
)
.Execute();