抑制 LINQ to SQL DBML 警告

发布于 2024-09-29 05:59:05 字数 406 浏览 0 评论 0原文

我已经从不受我控制的数据库生成了 LINQ to SQL 类,该数据库有很多 Decimal(38, 5) 字段。显然 .NET Decimal 类型的范围比这个小,因此 LINQ to SQL 代码生成器会抛出很多警告:

DBML1008:从数据库加载时,“AddersAndMultiplier”类型的“StructGable24InchOCStuds”列中的 DbType“Decimal(38,5)”和类型“System.Decimal”之间的映射可能会导致数据丢失

这些字段中的任何一个都极不可能一个足够大的值,在实践中会导致数据丢失,所以我想抑制这些警告。但是,显然通过 VS 中的对话框设置警告抑制不适用于 LINQ to SQL 代码生成器警告 - 还有其他方法吗?

I've generated LINQ to SQL classes from a database not under my control which has a lot of Decimal(38, 5) fields. Apparently the range of the .NET Decimal type is smaller than this, so the LINQ to SQL code generator is throwing a lot of warnings:

DBML1008: Mapping between DbType 'Decimal(38,5)' and Type 'System.Decimal' in Column 'StructGable24InchOCStuds' of Type 'AddersAndMultiplier' may cause data loss when loading from the database

It's extremely unlikely that any of these fields will ever have a value big enough to cause data loss in practice so I'd like to suppress these warnings. However, apparently setting warning suppression through the dialog in VS doesn't work with LINQ to SQL code generator warnings - is there another method?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巾帼英雄 2024-10-06 05:59:05

我不确定如何抑制警告,但由于我可以控制导致系统出现问题的存储过程,因此我将返回值转换为较小的小数,从而消除了警告。

SELECT CAST(SUM(AdFee) AS DECIMAL(19, 3))

I am not sure how to suppress the warning but since I have control of the stored procedure that was causing the problem on my system I cast the return value to a smaller decimal which removed the warning.

SELECT CAST(SUM(AdFee) AS DECIMAL(19, 3))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文