一个查询中 用到了 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. linux 下执行.sh文件总是提示permission denied

      linux 下执行.sh文件总是提示permission denied 如果你是root登陆的话(不是的话,切换到root用户,对*.sh赋可执行的权限) chmod 777 *.sh or ch ...

  2. SQL Server根据列名查表

    select a.name, b.name from syscolumns a, sysobjects b where a.name = 'XXXX' and a.id = b.id and b.xt ...

  3. (转) Class

    Classes are an expanded concept of data structures: like data structures, they can contain data memb ...

  4. (原)使用mkl计算特征值和特征向量

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5585271.html 参考文档:mkl官方文档 lapack_int LAPACKE_sgeev(in ...

  5. 用GDAL/OGR去读shapefile

    一.读shapefile 1.首先,用Arcgis创建所要读的shp文件.打开ArcCatalog,右键NEW->Shapefile,名称Name:point ,要素类型(Feature Typ ...

  6. jdk配置环境变量

    介绍在linux下配置jdk环境变量的几种常用方法. 首先在linux下安装jdk,如果出现提示权限不够(且root下也提示权限不够),可用#ls -l filename命令查看一下,如果显示类似如: ...

  7. 快速制作规则及获取规则提取器API

    1. 引言 前面文章的测试案例都用到了集搜客Gooseeker提供的规则提取器,在网页抓取工作中,调试正则表达式或者XPath都是特别繁琐的,耗时耗力,工作枯燥,如果有一个工具可以快速生成规则,而且可 ...

  8. LinqToSql 小例子

    namespace LinqToSqlDemo.Test { class Program { // 数据连接文本 private static DataClasses1DataContext data ...

  9. joseph-约瑟夫环问题

    约瑟夫环运作如下: 1.一群人围在一起坐成环状(如:N) 2.从某个编号开始报数(如:K) 3.数到某个数(如:M)的时候,此人出列,下一个人重新报数 4.一直循环,直到所有人出列,约瑟夫环结束 关于 ...

  10. 电子工程师名片——UFI Command,USB盘符的显示

    USB Mass Storage类规范概述        USB Mass storage Device协议即海量存储设备协议适用于硬盘,U盘等大容量存储设备.协议使用的接口端点有BulkIn.Bul ...