一个查询中 用到了 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. T4模板试水篇1_入门

    T4模板作为VS自带的一套代码生成器,功能有多强大我也不知道,最近查找了一些资料学习一下,做个笔记 更详细的资料参见: MSDN: http://msdn.microsoft.com/zh-cn/li ...

  2. textView富文本点击事件

    NSDictionary * attDic = [NSDictionary dictionaryWithObjectsAndKeys:RGBCOLOR(31, 132, 204),NSForegrou ...

  3. poj1716 Integer Intervals(差分约束)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Integer Intervals Time Limit: 1000MS   Me ...

  4. python调用ice接口

    今天用python调用ice接口,遇到如下提示 ImportError: No module named Ice 解决方案是 set PYTHONPATH=C:\Program Files\ZeroC ...

  5. self和this的不同

    在Java和C++中,this总是指的是当前实例地址,而在静态方法也就是类方法中,是不可以使用this的.在Objectvie-C中,self是既可以出现在实例方法中,也可以出现在类方法中,并且在不同 ...

  6. 分享一个jdk源码链接

    请查看下面的链接:http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/bcba89ce0a8c/src/share/classes/,进入页面后,点击列表中 ...

  7. jquery获取当前鼠标所在位置的坐标

    $(document).ready(function(){ $(document).mousemove(function(e){ $('#xy').html("X :"+e.pag ...

  8. Sumblime Text 2 常用插件以及安装方法

    1.直接安装 安装Sublime text 2插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->packages). 2.使用Package C ...

  9. Python学习笔记一,输入输出

    输出:用print()在括号中加上字符串,就可以向屏幕上输出指定的文字.比如输出'hello, world',用代码实现如下>>>print('hello,world') 也可以是多 ...

  10. 黑马程序员 1、C语言32个关键字整理分类

    ------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------ C语言一共有32个关键字 一.数据类型关键字(共20个) A.基本数据类型(5个)void :声明 ...