Count
Daisychain the Count
method to the end of a column selection return the number of non-null items in that group.
- Unless otherwise aliased, or cast to a scalar value, you can access the count value in the returned SimpleRecord object using the empty string as a key
- To return the number of null and non-null items using a count(*) statement, please use the GetCount or GetCountBy methods.
Examples
1
To return a count of the non-null values for the OrderId column in OrderDetails, use the following command:
var details = db.OrderDetails.All() .Select( db.OrderDetails.OrderId.Count());
Simple.Data sends the following SQL to the database when details is evaluated
select Count([dbo].[OrderDetails].[OrderId]) from [dbo].[OrderDetails]