使用'Let'有危险吗? [英] Is there a danger using 'Let'?

查看:82
本文介绍了使用'Let'有危险吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现了在我的Linq-to-Entities查询中使用Let的功能,我一直在试验它的功能。  由于它们类似于查询变量,我开始为变量分配实体属性,然后创建其他变量
以使用先前定义的变量运行数学。  显然,我可以通过这种方式深入学习,但是计算是否转换为数据库查询,还是应用程序使用数据库返回的值进行数学计算?  我问的
原因是我总是被告知要尽可能简化数据库流程,我担心Let的复杂用法会导致性能损失。


您的想法?

I recently discovered the power of using Let in my Linq-to-Entities queries and I've been experimenting with its capabilities.  Since they're like in-query variables, I started assigning entity properties to the variables, then creating other variables to run math against using previously defined variables.  Obviously, I can get pretty deep in the math this way but is the calculation translated to a database query or is the math done in the application with values returned from the database?  The reason I ask is I've always been told to keep the database processes as simple as possible and I fear complex usages of Let can cause some performance loss.

Your thoughts?

推荐答案

您好,

让关键字可以方便地用于在查询中为表达式结果创建标识符。有时,它可以改善性能,例如,它会存储结果,因此您需要多次评估
。使用let关键字没有危险。如果您的源代码中有这些代码片段,为什么不在这里发布危险和性能损失?

Let keyword is convinient for use to create an identifier for a expression result in a query. Sometimes, it could improve the performance, for example, it stores a result so that you don't need to evaluate for multiple times. There is no danger using let keyword. Why not posting a code snippet here for the danger and performance loss if there are in your source code?

问候


这篇关于使用'Let'有危险吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆