人大金仓sqlserver模式uniqueidentifer类型和uuid类型的判断问题 返回
项目中的代码:
var exportConfig = await db.Queryable<DataExportConfig>()
.Includes(r => r.ExportDetails)
.Where(r => r.Id==exportInput.ConfigId)
.FirstAsync();
其中r.id和exportInput.ConfigId,的属性分别为Guid?和Guid类型,执行后,生成的语句如下:
SELECT "id","name","parameters","sys_id","sys_user","sys_date","sys_muser","sys_mdate","sys_valid","sys_batchid","sys_epsid" FROM "D_DataExportConfig" WHERE ("id" = N'b83e87ee-25fb-4934-aa2f-264b4faacbb4') LIMIT 1 offset 0
此SQL语句在金仓的Kstudio中可以执行,但是代码在项目执行会报错,堆栈如下:
Kdbndp.KingbaseException (0x80004005): 42883: operator does not exist: uniqueidentifier = uuid
at Kdbndp.KdbndpConnector.<>c__DisplayClass166_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location ---
at Kdbndp.KdbndpConnector.<>c__DisplayClass166_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location ---
at Kdbndp.KdbndpDataReader.NextResult(Boolean async, Boolean isConsuming)
at Kdbndp.KdbndpCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at SqlSugar.AdoProvider.GetDataReaderAsync(String sql, SugarParameter[] parameters)
at SqlSugar.QueryableProvider`1.GetDataAsync[TResult](KeyValuePair`2 sqlObj)
at SqlSugar.QueryableProvider`1._ToListAsync[TResult]()
at SqlSugar.QueryableProvider`1.FirstAsync()
at Jetop.Service.DataService.ToolsService.QueryDataInExportConfig(DataExportInput exportInput) in E:\工作\2024\net\Jetop.Service.DataService\Jetop.Service.DataService\Services\Tools\ToolsService.cs:line 403
at lambda_method179(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
金仓为SQLServer模式,SqlSugarCore 版本:5.1.4.169,SqlSugarCore.Kdbndp 版本:9.3.6.801
热忱回答(6)
-
fate sta VIP02周前
.Includes(r => r.ExportDetails)
.Where(r => r.Id==exportInput.ConfigId)
是includes报错还是where报错讲清楚
0 回复 -
火之占卜者 VIP02周前
回禀大佬,我把includes注释掉,依然会报错,应该是where部分报错
另外,我尝试了这样的写法
Where(r => r.Id.ToString().ToLower()==exportInput.ConfigId.ToString().ToLower())
形成的sql如下:
SELECT "id","name","parameters","sys_id","sys_user","sys_date","sys_muser","sys_mdate","sys_valid","sys_batchid","sys_epsid" FROM "D_DataExportConfig" WHERE ((LOWER( CAST("id" AS VARCHAR))) = (LOWER( CAST(N'b83e87ee-25fb-4934-aa2f-264b4faacbb4' AS VARCHAR))) ) LIMIT 1 offset 0
项目会报这样一个错误
Kdbndp.KingbaseException (0x80004005): 22001: value too long for type varchar(30)
0 回复 -
fate sta VIP02周前
数据库使用uuid类型,目前我这边sqlserver模式创建不了
uniqueidentifer
类型
0 回复 -
fate sta VIP02周前
如果你是最新版本的库支持uniqueidentifer那就要找金仓官方去协调兼容
0 回复 -
火之占卜者 VIP02周前
好的,我们正在跟金仓技术那边沟通,据说会更新驱动,我想问一下如果官方更新了驱动,咱们这边通常多长时间会同步更新
0 回复 -
fate sta VIP02周前
@火之占卜者:你和他们沟通一下,只要他们给到我我这边就会更新
0 回复