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

freesql打印sql语句是:INSERT INTO articulo(ID, CN) VALUES('1', 'Ь×Ó'),为什么执行就变成1 D?¡Á¨? #1241

Closed
ZevFung opened this issue Sep 9, 2022 · 4 comments

Comments

@ZevFung
Copy link

ZevFung commented Sep 9, 2022

问题描述及重现步骤:

Ь×Ó 来自

var s = "鞋子";
byte[] bytesStr1 = Encoding.GetEncoding("gb2312").GetBytes(s);
var ss = Encoding.GetEncoding("latin1").GetString(bytesStr1);  //Ь×Ó
fsql.Aop.AuditValue += (s, e) =>
                {
                    if (e.Property.PropertyType == typeof(string) && e.Value != null && !string.IsNullOrWhiteSpace(e.Value.ToString()))
                    {
                        byte[] bytesStr1 = Encoding.GetEncoding("gb2312").GetBytes(e.Value.ToString());
                        e.Value = Encoding.GetEncoding("latin1").GetString(bytesStr1);
                    }
                };

var aa = _articuloRepository.Orm.Insert(entity).ToSql();
var ss = await _articuloRepository.Orm.Insert(entity).ExecuteAffrowsAsync();
或者
await _articuloRepository.InsertAsync(entity);

freesql打印sql语句是:INSERT INTO articulo(ID, CN) VALUES('1', 'Ь×Ó'),为什么执行就变成1 D?¡Á¨?

用下面的执行

var ss = await _articuloRepository.Orm.Ado.ExecuteNonQueryAsync(@"INSERT INTO `articulo`(`ID`, `CN`) VALUES('1', 'Ь×Ó')");

但这样执行正常插入INSERT INTO articulo(ID, CN) VALUES('1', 'Ь×Ó')

数据库的具体版本

mysql 5.6.31 数据库编码latin1

安装的包

3.2.666-preview20220829

.net framework/. net core? 及具体版本

.net core 3.1
@2881099
Copy link
Collaborator

2881099 commented Sep 9, 2022

关于编码,需要检查数据库,数据库表,连接字符串。

@ZevFung
Copy link
Author

ZevFung commented Sep 9, 2022

关于编码,需要检查数据库,数据库表,连接字符串。

var ss = await _articuloRepository.Orm.Ado.ExecuteNonQueryAsync(@"INSERT INTO articulo(ID, CN) VALUES('1', 'Ь×Ó')");也正常执行,为啥var ss = await _articuloRepository.Orm.Insert(entity).ExecuteAffrowsAsync();
或者
await _articuloRepository.InsertAsync(entity);就不正常执行?

@hd2y
Copy link
Contributor

hd2y commented Sep 9, 2022

需要先检查传递进来的 entity 属性值是不是就已经乱码了。

@2881099
Copy link
Collaborator

2881099 commented Sep 16, 2022

原因是仓储执行了两次 Aop.AuditValue,前几天已经处理了。

2881099 added a commit that referenced this issue Sep 16, 2022
2881099 added a commit that referenced this issue Sep 24, 2022
2881099 added a commit that referenced this issue Sep 25, 2022
@2881099 2881099 closed this as completed Oct 2, 2022
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