Example in LINQPad against adventureworks selfservicing
SalesOrderDetail.Sum (sod => sod.SalesOrderDetailID)
and
var orderDetails = new SalesOrderDetailCollection();
var orderPrice = orderDetails.GetScalar(SalesOrderDetailFieldIndex.SalesOrderID, AggregateFunction.Sum);
both produce Arithmetic overflow error as sum goes above max int
ORMQueryExecutionException
An exception was caught during the execution of a retrieval query: Arithmetic overflow error converting expression to data type int.. Check InnerExcep...
Message
An exception was caught during the execution of a retrieval query: Arithmetic overflow error converting expression to data type int.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
InnerException
SqlException
Arithmetic overflow error converting expression to data type int.
TargetSite
RuntimeMethodInfo
RetrievalQuery.ExecuteScalar ()
StackTrace
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.ExecuteScalar()
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteScalarQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction)
at AW.Data.DaoClasses.CommonDaoBase.ExecuteScalarQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction)
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetScalar(IEntityFields fields, ITransaction containingTransaction, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause, Boolean allowDuplicates)
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetScalar(IEntityFields fields, ITransaction containingTransaction, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause)
at AW.Data.CollectionClasses.SalesOrderDetailCollection.GetScalar(SalesOrderDetailFieldIndex fieldIndex, IExpression expressionToExecute, AggregateFunction aggregateToApply, IPredicate filter, IRelationCollection relations, IGroupByCollection groupByClause)
at AW.Data.CollectionClasses.SalesOrderDetailCollection.GetScalar(SalesOrderDetailFieldIndex fieldIndex, AggregateFunction aggregateToApply)
Source
SD.LLBLGen.Pro.ORMSupportClasses
HResult
-2146232832
RuntimeVersion
4.2.0.0
RuntimeBuild
10232014
QueryExecuted
Query: SELECT TOP(@p2) SUM([AdventureWorks].[Sales].[SalesOrderDetail].[SalesOrderID]) AS [SalesOrderID] FROM [AdventureWorks].[Sales].[SalesOrderDetail]
Parameter: @p2 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 1.
None Int64 0 @p2 0 0 BigInt 1 1 Input False 0 0 False Current
ErrorCode -2146232060
Message Arithmetic overflow error converting expression to data type int.
HelpLink null
ErrorNumber 8115
.Net SqlClient Data Provider 8115 2 16 (localdb)\MSSQLLocalDB Arithmetic overflow error converting expression to data type int. 1
SD.LLBLGen.Pro.ORMSupportClasses.dll V4.2.14.1023