使用LINQ查询过滤,但它正在选择特定的密钥很多次 [英] Using LINQ Query to Filter but it is selecting the particular Key Numerous times

查看:38
本文介绍了使用LINQ查询过滤,但它正在选择特定的密钥很多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我正在尝试使用LINQ to SQL从表(_dtlayout)查询。我正在尝试选择列名FK_DataPoint。

但是当我调试它时,它会多次击中该列。它不会引起任何错误,但对性能而言,它是一个主要问题。我知道我正在使用Where子句,它会遍历每一行并过滤它。但有没有更好的方法将此代码放在一起以过滤此DATAPOINT列。谢谢 。



Hi all i am trying to Query from a table (_dtlayout) using the LINQ to SQL. I am trying to select a column name FK_DataPoint.
But when i Debug it out it is hitting that column numerous times. It does not throw any ERROR but for Performance wise it is a major issue. I know i am using a Where clause which goes to each rows and filters it. But is there a better way to put this code together in order to filter this DATAPOINT Column. Thank you .

int? dataPointKey = _dtLayout.AsEnumerable().
    Where(row => row.Field<int?>("FK_FinancialStatementTemplateSectionItem") 
== colDef.FK_FinancialStatementTemplateSectionItem 
&& row.Field<int?>("RowNumber") == columnItem.RowNumber
&& row.Field<int?>("ColumnNumber") == colDef.ColumnNumber
&& row.Field<int?>("ItemNumber") == columnItem.ItemNumber)                                
.Select (row =>row.Field<int?>("FK_DataPoint")).FirstOrDefault();





谢谢



Thanks

推荐答案

您正在使用单个查询。使用f11键,所以如果你使用f10就会多次击中它会在几分之一秒内执行。因此不存在更大的性能问题。
You are using a single query. U r using f11 key and so it is hitting many times if u use f10 it'll execute with in a fraction of seconds.So there will be no bigger performance issue.


这篇关于使用LINQ查询过滤,但它正在选择特定的密钥很多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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