We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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.Provider.PostgreSQL v3.2.640+
第一步:单独引用 Npgsql.NetTopologySuite.dll 6.0.4
原因是 npgsql 6.0+ 才处理了 numeric -> BigInteger 映射
如果不升级报错 Can't cast database type numeric to BigInteger
第二步:处理读取,AOP 事件全局设置一次
如果不处理报错 Numeric value does not fit in a System.Decimal
fsql.Aop.AuditDataReader += (_, e) => { var dbtype = e.DataReader.GetDataTypeName(e.Index); var m = Regex.Match(dbtype, @"numeric\((\d+)\)", RegexOptions.IgnoreCase); if (m.Success && int.Parse(m.Groups[1].Value) > 19) e.Value = e.DataReader.GetFieldValue<BigInteger>(e.Index); //否则会报溢出错误 };
第三步:测试添加、更新、查询
class tuint256tb_01 { public Guid Id { get; set; } public BigInteger Number { get; set; } } var num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968"); fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows(); if (1 != fsql.Insert(new tuint256tb_01()).ExecuteAffrows()) throw new Exception("not equal"); var find = fsql.Select<tuint256tb_01>().ToList(); if (find.Count != 1) throw new Exception("not single"); if ("0" != find[0].Number.ToString()) throw new Exception("not equal"); var item = new tuint256tb_01 { Number = num }; if (1 != fsql.Insert(item).ExecuteAffrows()) throw new Exception("not equal"); find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList(); if (find.Count != 1) throw new Exception("not single"); if (item.Number != find[0].Number) throw new Exception("not equal"); num = num - 1; item.Number = num; if (1 != fsql.Update<tuint256tb_01>().SetSource(item).ExecuteAffrows()) throw new Exception("not equal"); find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList(); if (find.Count != 1) throw new Exception("not single"); if ("57896044618658097711785492504343953926634992332820282019728792003956564819967" != find[0].Number.ToString()) throw new Exception("not equal"); num = BigInteger.Parse("57896044618658097711785492504343953926634992332820282019728792003956564819968"); fsql.Delete<tuint256tb_01>().Where("1=1").ExecuteAffrows(); if (1 != fsql.Insert(new tuint256tb_01()).NoneParameter().ExecuteAffrows()) throw new Exception("not equal"); find = fsql.Select<tuint256tb_01>().ToList(); if (find.Count != 1) throw new Exception("not single"); if ("0" != find[0].Number.ToString()) throw new Exception("not equal"); item = new tuint256tb_01 { Number = num }; if (1 != fsql.Insert(item).NoneParameter().ExecuteAffrows()) throw new Exception("not equal"); find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList(); if (find.Count != 1) throw new Exception("not single"); if (item.Number != find[0].Number) throw new Exception("not equal"); num = num - 1; item.Number = num; if (1 != fsql.Update<tuint256tb_01>().NoneParameter().SetSource(item).ExecuteAffrows()) throw new Exception("not equal"); find = fsql.Select<tuint256tb_01>().Where(a => a.Id == item.Id).ToList(); if (find.Count != 1) throw new Exception("not single"); if ("57896044618658097711785492504343953926634992332820282019728792003956564819967" != find[0].Number.ToString()) throw new Exception("not equal");
The text was updated successfully, but these errors were encountered:
- 增加 pgsql numeric -> BigInteger 映射;#1100
fc32710
v3.2.640 #1103 #1100 #1099 #1098 #1097
d6a6798
No branches or pull requests
确实已安装:FreeSql.Provider.PostgreSQL v3.2.640+
第一步:单独引用 Npgsql.NetTopologySuite.dll 6.0.4
原因是 npgsql 6.0+ 才处理了 numeric -> BigInteger 映射
如果不升级报错 Can't cast database type numeric to BigInteger
第二步:处理读取,AOP 事件全局设置一次
如果不处理报错 Numeric value does not fit in a System.Decimal
第三步:测试添加、更新、查询
The text was updated successfully, but these errors were encountered: