一个查询中 用到了 sum , 可是返回结果的小数有很多位 , 都不准确了..类似js中的小数运算一样...不太熟悉C#,不知道这问题是因为double的关系 , 还是因为代码写的问题 ,

通过 sql server profile 获取的sql语句执行后都是没有问题的

这是我的代码:

var query = db.SupDataGreenAccount1
.Where(lambda)
.GroupBy( p => new{
p.ObjPos , p.District , p.Feature
})
.Select(
p => new {
     //area是 double , 数据库中是 float
sums = p.Sum(c => (double?)c.Area ?? 0),
objpos = p.Key.ObjPos ,
district = p.Key.District ,
feature = p.Key.Feature
}); var ss = query.ToArray(); var list = query.ToList();

这是调试中获取的数据:

这是 sql server profile 执行的sql:

SELECT
1 AS [C1],
[GroupBy1].[A1] AS [C2],
[GroupBy1].[K1] AS [ObjPos],
[GroupBy1].[K3] AS [DISTRICT],
[GroupBy1].[K2] AS [FEATURE]
FROM ( SELECT
[Extent1].[ObjPos] AS [K1],
[Extent1].[FEATURE] AS [K2],
[Extent1].[DISTRICT] AS [K3],
SUM([Extent1].[AREA]) AS [A1]
FROM [dbo].[Sup_Data_GreenAccount_1] AS [Extent1]
WHERE (1 = 1) AND (( CAST(CHARINDEX([Extent1].[DISTRICT], N'保税区') AS int)) > 0)
GROUP BY [Extent1].[ObjPos], [Extent1].[FEATURE], [Extent1].[DISTRICT]
) AS [GroupBy1]

这是执行上面的SQL返回的结果:

EntityFramework sum嵌套的更多相关文章

  1. [LeetCode] Nested List Weight Sum 嵌套链表权重和

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  2. [leetcode]339. Nested List Weight Sum嵌套列表加权和

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  3. [leetcode]364. Nested List Weight Sum II嵌套列表加权和II

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  4. 【leetcode】339. Nested List Weight Sum

    原题 Given a nested list of integers, return the sum of all integers in the list weighted by their dep ...

  5. python基础3、4---流程控制、运算符

    1.for循环 和while循环 for 临时变量 in 待遍历的数据: 循环体 (循环体这里一般加break,结束循环,执行else代码) else: 循环不满足条件执行的代码 while  表达式 ...

  6. LinkedIn TAG

                 List1  [leetcode]243. Shortest Word Distance最短单词距离 Two Pointers [leetcode]244. Shortest ...

  7. LeetCode 339. Nested List Weight Sum (嵌套列表重和)$

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  8. [Swift]LeetCode339. 嵌套链表权重和 $ Nested List Weight Sum

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  9. 【原创】从 列表的重复 到 用sum展开二层嵌套列表将子元素合并

      转载请注明出处:https://www.cnblogs.com/oceanicstar/p/9517159.html     ★像R语言里头有rep函数可以让向量的值重复,在python里面可以直 ...

随机推荐

  1. orcl 行转列的存储过程

    CREATE or replace PROCEDURE sp_fixWage AUTHID CURRENT_USER as --此处需要注意的 authid current_user 这个属性  详细 ...

  2. Python3.5入门学习记录-函数

    Python 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也 ...

  3. C++程序设计实践指导1.14字符串交叉插入改写要求实现

    改写要求:1:以指针为数据结构开辟存储空间 改写要求2:被插入字符串和插入字符串不等长,设计程序间隔插入 如被插入字符串长度为12,待插入字符串长度为5 则插入间隔为2 改写要求3:添加函数Inser ...

  4. (原)Ubuntu16中编译caffe

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5797526.html 参考网址: http://caffe.berkeleyvision.org/in ...

  5. java使用dom4j和XPath解析XML与.net 操作XML小结

    最近研究java的dom4j包,使用 dom4j包来操作了xml 文件 包括三个文件:studentInfo.xml(待解析的xml文件), Dom4jReadExmple.java(解析的主要类), ...

  6. 各种浏览器的agent信息(IE Chrome Safari Firefox)

    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/53 ...

  7. grep;egrep;fgrep

    -1 使用场景:搜索定位内容并输出(所在行) -2 三者区别: --1 grep  默认支持普通正则 --2 egrep 默认支持扩展正则 等同于 grep -E --3 fgrep 速度最快,不支持 ...

  8. 火星A+B

    火星A+B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  9. Node.js how to respond to an upgrade request?

    You just need to call socket.write with the appropriate HTTP syntax as plain text along these lines ...

  10. 验证abc三列数字符合我的小弟要求

    需求好像是: 1.第一列数据有重复的找出来,并且找出它的重复位置 2.第三列根据第一列得出的位置,取出相应位置的数据进行相加 3.相加的结果 是否等同于第二列的对应位置数据 <!DOCTYPE ...