在线等!!!急急急!!!翻译LINQ语句

zyglovewhj 2010-09-26 03:03:32
select '收入' as kemu,isnull(sum(money),0)as money
from [statistics]
where SortType =1 and SortId in (
select Id from CashflowSort where CorpMoneySign =1)

union all

select '--'+c.Title,c.Allmoney from (
select Title,isnull(SUM(money),0) Allmoney,CorpMoneySign ,a.Id
from CashflowSort a
left join [statistics]
on
SortType=1 and a.Id= SortId
group by Title,CorpMoneySign,a.Id) c
where c.corpMoneySign =1 and c.Id not in
(select distinct ParentId from CashflowSort )

翻译成LINQ
...全文
167 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
huminghua 2010-09-27
  • 打赏
  • 举报
回复

最后你要的结果:
var listID=from c in CashflowSort
where c.CorpMoneySign ==1
select c.Id;
var lList=from a in CashflowSort join s in statistics
on s.SortType==1 && a.SortId==s.SortId into ss
group ss by new
{
ss.Title,
ss.CorpMoneySign,
ss.Id
} into ssa
select new
{
Title=ssa.Title,
Allmoney=ssa.Sum(ssa=>ssa.money)==null?0:ssa.Sum(ssa=>ssa.money),
CorpMoneySign=ssa.CorpMoneySign,
ssa.Id
};

var dl=(from cf in CashflowSort select cf.ParentId).Distinct();

(from s in statistics
group s by s.money into t
where s.SortType ==1
&& listID.Contains(s.SortId)
select new
{
kemu='收入',
money=t.Sum(t=>t.money)==null?0:t.Sum(t=>t.money)
}).Contact(from c in lList where c.corpMoneySign==1 && !(dl).Contains(c.Id) select new{'--'=c.Title,c.Allmoney})

huminghua 2010-09-27
  • 打赏
  • 举报
回复
select '--'+c.Title,c.Allmoney from (
select Title,isnull(SUM(money),0) Allmoney,CorpMoneySign ,a.Id
from CashflowSort a
left join [statistics]
on
SortType=1 and a.Id= SortId
group by Title,CorpMoneySign,a.Id) c
where c.corpMoneySign =1 and c.Id not in
(select distinct ParentId from CashflowSort )

翻译成LINQ
var lList=from a in CashflowSort join s in statistics
on s.SortType==1 && a.SortId==s.SortId into ss
group ss by new
{
ss.Title,
ss.CorpMoneySign,
ss.Id
} into ssa
select new {'--'=ssa.Title,ssa.Allmoney};

var dl=(from cf in CashflowSort select cf.ParentId).Distinct();

var nextQuery=from c in lList where c.corpMoneySign==1 && !(dl).Contains(c.Id)
huminghua 2010-09-27
  • 打赏
  • 举报
回复
恩!楼上多说对啦!我没仔细写。。幸好你指出来!谢谢!我也是才刚学Linq想来这里学习一下!嘿嘿!楼上好仔细哦!呵呵!
q107770540 2010-09-27
  • 打赏
  • 举报
回复


select '收入' as kemu,isnull(sum(money),0)as money
from [statistics]
where SortType =1 and SortId in (
select Id from CashflowSort where CorpMoneySign =1)

//针对上边的SQL 语句,我写了下边的LINQ
var listID=from c in CashflowSort
where c.CorpMoneySign ==1
select c.Id;

var query= from s in statistics
group s by s.money into t
where s.SortType ==1
&& listID.Contains(s.SortId)
select new
{
kemu='收入',
money=t.Sum(t=>t.money)==null?0:t.Sum(t=>t.money)
}

q107770540 2010-09-27
  • 打赏
  • 举报
回复
and 在linq中应该是 && 吧。。
q107770540 2010-09-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 huminghua 的回复:]

(from s in statistics where s.SortType=1 and (from c in CashflowSort where c.CorpMoneySign==1 select c.Id).Contains(s.SortType) select new{'收入' as s.kemu,isnull(statistics.Sum(a=> a.money),0) as s.mo……
[/Quote]
据我所知
1.linq语句中where后应该是== 吧: where s.SortType==1
select new 中应该这样写吧:


select new
{
收入 = s.kemu,
money= statistics.Sum(a=> a.money)==null?O:statistics.Sum(a=> a.money))
}
哥子谭 2010-09-27
  • 打赏
  • 举报
回复
问题怎么这么复杂哦
huminghua 2010-09-27
  • 打赏
  • 举报
回复
谢谢楼上的啊!你不来回复我就回复不了啦!
huminghua 2010-09-27
  • 打赏
  • 举报
回复
(from s in statistics
group s by s.money into t
where s.SortType ==1
&& listID.Contains(s.SortId)
select new
{
kemu='收入',
money=t.Sum(t=>t.money)==null?0:t.Sum(t=>t.money)
}).Concat
(from c in lList where c.corpMoneySign==1 && !(dl).Contains(c.Id)
select new
{
c.Title='--',
c.Allmoney
}
)
不知道是否正确!你自己试试!请高手指点一二! //一个用户只允许连续回复3次。连续是指的多久啊!
mingming912 2010-09-27
  • 打赏
  • 举报
回复
好复杂
bancxc 2010-09-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 huminghua 的回复:]
(from s in statistics where s.SortType=1 and (from c in CashflowSort where c.CorpMoneySign==1 select c.Id).Contains(s.SortType) select new{'收入' as s.kemu,isnull(statistics.Sum(a=> a.money),0) as s.mon……
[/Quote]nb.
huminghua 2010-09-26
  • 打赏
  • 举报
回复
(from s in statistics where s.SortType=1 and (from c in CashflowSort where c.CorpMoneySign==1 select c.Id).Contains(s.SortType) select new{'收入' as s.kemu,isnull(statistics.Sum(a=> a.money),0) as s.money}).Contact
(后面的自己写) 貌似没有ISNUll这个,你换成=吧!呵呵~!
内容概要:本文聚焦于“通过ADMM进行TV-L1去噪”的研究,系统阐述了基于交替方向乘子法(ADMM)实现总变差(Total Variation, TV)正则化与L1范数稀疏约束相结合的图像去噪模型。文中详细解析了TV-L1模型的数学构建及其在抑制椒盐噪声、保持图像边缘结构方面的优越性,重点介绍了ADMM算法如何将复杂的凸优化问题分解为多个可高效求解的子问题,提升收敛效率与数值稳定性。配套提供的Matlab代码实现了完整的去噪流程,便于读者复现算法并开展实验验证。此外,文档还整合了电力系统、信号处理、路径规划、机器学习等多个领域的科研资源,凸显其作为综合性学术资料包的价值。; 适合人群:具备良好数学基础与Matlab编程能力,从事图像处理、信号去噪、优化算法或相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 深入理解并复现基于ADMM的TV-L1图像去噪算法;② 掌握总变差正则化与L1范数在稀疏噪声去除中的理论与应用;③ 利用所提供的Matlab代码进行算法调试、性能评估与二次开发;④ 借助附带的多领域科研案例拓展研究思路,推动跨学科技术创新。; 阅读建议:建议读者结合理论推导与Matlab代码实践,逐步跟踪ADMM的迭代过程,观察其收敛行为与去噪效果,同时可参考文档末尾提供的丰富科研资源链接,拓展技术视野与研究深度。
内容概要:本文档为一篇博士论文的复现资料,聚焦于计及锁相环频率耦合效应的光伏逆变器序阻抗解析建模与扫频稳定评估研究。基于Matlab编程与Simulink仿真平台,构建了包含锁相环动态特性的光伏并网逆变器正负序阻抗模型,深入剖析其在弱电网条件下因锁相环引发的频率耦合机制,并采用小信号扫频法进行阻抗特性辨识与系统稳定性分析。文档系统呈现了理论建模的数学推导过程、仿真模型搭建细节及核心代码实现,旨在完整复现并验证原论文的关键研究成果,帮助使用者掌握新能源发电系统接入弱电网时的小信号稳定性分析方法与技术路径。; 适合人群:具备电力电子、自动控制及电力系统稳定性相关基础知识,熟练掌握Matlab/Simulink仿真工具,从事新能源并网技术、微电网稳定性分析、逆变器控制策略研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 深入理解光伏逆变器序阻抗建模理论,特别是锁相环导致的正负序频率交叉耦合现象;② 掌握基于扫频法的阻抗测量与奈奎斯特稳定性判据应用,评估并网系统的稳定裕度;③ 复现高水平学术论文的核心成果,为自身科研项目提供可靠的理论依据、成熟的代码框架与仿真技术参考。; 阅读建议:学习者应结合所提供的Matlab代码与Simulink仿真模型,循序渐进地理解阻抗建模的理论推导与实现逻辑,重点在于动手调试扫频模块以获取精确的阻抗频率响应曲线,并通过调整控制器参数、电网强度等变量,观察其对系统阻抗特性与稳定性的影响,从而深化对理论知识的实践应用与创新能力。

8,492

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 LINQ
社区管理员
  • LINQ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧