Will this LINQ-TO-SQL query fetch all records from the table ?

Posted by Puneet Dudeja on Stack Overflow See other posts from Stack Overflow or by Puneet Dudeja
Published on 2010-12-30T08:13:10Z Indexed on 2010/12/31 19:53 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
public long GetNewCRN()
{
   return ((from c in DataContext.GetTable<Cust_Master>() 
            select c.CUSTSERH_CRN).Max() + 1);
}

Will this Linq to Sql query fetch all records from the table first and then select the maximum of the column ?

If yes, then isn't it a bad idea using linq to sql instead of normal SqlCommand ?

Or is there any other way of doing it in linq to sql ?


When I attach Console.Out, I see nothing(command prompt does not even open).

But when I include following:-

context.Log = new System.IO.StreamWriter("d:\\abcd.txt");

I get an error, that "The process can not access the file because it is being used by another process" and that process is "w3wp.exe".

How can I see the sql commands being executed by DataContext then ?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about LINQ