简体   繁体   English

Dapper错误地认为列数值

[英]Dapper incorrectly thinking Column Numeric

I have been using dapper for a while but have come across a strange issue. 我使用dapper已有一段时间,但遇到一个奇怪的问题。

I have a Column in a database table called , in my query my Table 我的查询表中有一个名为的数据库表中的列

my dapper query is 我的小巧的查询是

SELECT p.Id PaymentId, p.AmountPaid PaymentAmountPaid, np.NoticeNo PaymentRef

In the Database the column NoticeNo is defined as nchar 在数据库中,NoticeNo列定义为nchar

When I query it, its mapped to class with the following property 当我查询它时,它映射到具有以下属性的类

public string PaymentRef { get; set; }

I query as follows connection.Query<PaymentSummary>(sqlStr) 我查询如下connection.Query<PaymentSummary>(sqlStr)

but very strange, dapper seems to think that the NoticeNo column is a number, so if the store notice no as 1234 then when its queried the result is 1234.00 但是非常奇怪,dapper似乎认为NoticeNo列是一个数字,因此,如果商店notification1234,则当其查询时结果为1234.00

Most of the notice numbers are numeric, but they don't have to be. 大多数通知号是数字,但不是必须的。

Any ideas? 有任何想法吗?

Thanks ash. 谢谢灰。

Turns out it wasn't Dapper's Fault. 原来那不是Dapper的错。 The query was part of a union, and I had the notice no and the amount column in a different order in two if the queries, which was forcing the result to be a Number!! 该查询是联合的一部分,如果有查询,我将not通知和金额列按两个不同的顺序排列,这将结果强制为数字!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM