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

sql中CAST()类型转换,索引失效 #331

Open
253696936 opened this issue Aug 7, 2022 · 2 comments
Open

sql中CAST()类型转换,索引失效 #331

253696936 opened this issue Aug 7, 2022 · 2 comments

Comments

@253696936
Copy link

MySQL数据库
SysStatus字段类型为smallint
生成的sql语句使用了CAST类型转化,索引失效
SELECT ExcelSheet.ID AS ID,ExcelSheet.Name AS Name FROM ExcelSheet AS ExcelSheet WHERE (ExcelSheet.UserID = ?P_0 AND CAST(ExcelSheet.SysStatus AS SIGNED) = 1 AND ExcelSheet.ID IN (3))
请问是基于什么原因要进行类型转化?

@shuxinqin
Copy link
Owner

C#在包含int16类型得表达式树中好像有点特别,暂时没好解决方案,如果可以用int代替先吧~

@kygl
Copy link

kygl commented Nov 28, 2022

其实,一些数值类型的字段不进行转换就好了。一般使用时,实体已声名好类型,使用时也不会出错。

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

No branches or pull requests

3 participants