Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have one table in that there are more than 300 records.
I am doing operation for each record using LINQ. But it gets hang.

C#
var qryCkeckClocked = (from a in
                                             context.sp1
                                         select a);
foreach (var scan in qryCkeckClocked)
                    
var stud = (from ***
}

This is my code.
I think the query excutes with no of iteration to SQL.
Please suggest me
Posted
Updated 19-Jan-15 23:46pm
v3
Comments
OriginalGriff 20-Jan-15 4:17am    
That code fragment doesn't tell us very much: the second part won't even compile.
But what the first part does depends on what "context" is: if it's an IEmumerable such as a List, then it does nothing useful in practice!

We need to know more information: Use the "Improve question" widget to edit your question and provide better information.
Sinisa Hajnal 20-Jan-15 5:58am    
300 records is nothing, you shouldn't even feel the time of execution without having some bad-a$$ computing within.

1 solution

If you want to use join two table use Join function of LINQ instead of foreach. This query will create sql command like
VB
Select * from context.sp1


So instead of * you can select only desired table this will also reduce query execution time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900