Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CountAsync() await this.ToListAsync<int>() 数据条数大于int值引发异常 请调整数据类型。 #1896

Open
gaoshini112 opened this issue Oct 8, 2024 · 2 comments

Comments

@gaoshini112
Copy link

问题描述及重现代码:

CountAsync() await this.ToListAsync() 数据条数大于int值引发异常 请调整数据类型。

System.Exception: Value was either too large or too small for an Int32.
---> System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ThrowInt32OverflowException()
at System.Convert.ToInt32(UInt64 value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at lambda_method25(Closure , Type , Int32[] , DbDataReader , Int32 , CommonUtils )
at FreeSql.Internal.Utils.ExecuteArrayRowReadClassOrTuple(String flagStr, Type typeOrg, Int32[] indexes, DbDataReader row, Int32 dataIndex, CommonUtils _commonUtils)
at FreeSql.Internal.CommonProvider.Select0Provider2.<>c__DisplayClass102_11.b__0(FetchCallbackArgs1 fetch) at FreeSql.Internal.CommonProvider.AdoProvider.<>c__DisplayClass152_0.<ExecuteReaderAsync>b__0(FetchCallbackArgs1 fetch, Int32 result)
at FreeSql.Internal.CommonProvider.AdoProvider.ExecuteReaderMultipleAsync(Int32 multipleResult, DbConnection connection, DbTransaction transaction, Func3 fetchHandler, Action2 schemaHandler, CommandType cmdType, String cmdText, Int32 cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at FreeSql.Internal.CommonProvider.AdoProvider.LoggerException(IObjectPool1 pool, PrepareCommandResult pc, Exception ex, DateTime dt, StringBuilder logtxt, Boolean isThrowException) at FreeSql.Internal.CommonProvider.AdoProvider.ExecuteReaderMultipleAsync(Int32 multipleResult, DbConnection connection, DbTransaction transaction, Func3 fetchHandler, Action2 schemaHandler, CommandType cmdType, String cmdText, Int32 cmdTimeout, DbParameter[] cmdParms, CancellationToken cancellationToken) at FreeSql.Internal.CommonProvider.Select0Provider2.ToListQfPrivateAsync[TTuple](String sql, String field, CancellationToken cancellationToken)
at FreeSql.Internal.CommonProvider.Select0Provider`2.CountAsync(CancellationToken cancellationToken)

@2881099
Copy link
Collaborator

2881099 commented Oct 8, 2024

啥数据库,居然没有超时

@sampsonye
Copy link

CountAsync()返回类型为long不存在你说的问题

await this.ToListAsync<int>()建议改为await this.ToListAsync<long>() ,另,查询超过21亿条数据,正常不存在这个业务吧?建议先看看业务合理性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants