Home > Net >  Linq to SQL is lazy loading? What do you think?
Linq to SQL is lazy loading? What do you think?

Time:10-04

RT
Entering the Linq to SQL pit, here also don't understand the things, want to ask next,
For example:
 
Private void Button_Click (object sender, RoutedEventArgs e)
{
DataClasses1DataContext dc new DataClasses1DataContext ();
Console. WriteLine (" dc. DeferredLoadingEnabled: {0} ", dc, DeferredLoadingEnabled);//print out here is true

Var qa=the from p in dc. Table1 select p;
Qa=qa. The Where (p=& gt; (p.t 1 & lt; 5));
ListConsole. WriteLine (" list. The Count: {0} ", a list, Count);
}


Database is the following:


In this example, my colleagues and I had different opinions:
opinion a : I said should be a lazy loading, to use the "qa. ToList ();" When do the SQL query, only a single SQL statement, select out 3 records,
opinion 2 : but different opinion is that in debug mode, the execution of the "var qa=the from p in dc. Table1 select p;" See the result view of qa, is 5 records, the following figure, so he said linq is all the records will be taken back to the memory, and then do the where condition selection,



Want to ask the above two kinds of opinions, which right? Best can tell me the principle of reason
Please help everybody to give directions under
Any opinions, code, links, data can be, welcome to provide the relevant material, first thanked everybody!!








CodePudding user response:

Debug mode to see the equivalent output as a result, you use SQL server profiler tool monitoring what time executing SQL statements have result, check whether there is a line by line debugging SQL statement generated is ok,

CodePudding user response:

That I haven't seen, versus when you expand prompt "receive overtime?
"
Thing is to see you, you want to see the somebody else will give you see, don't you point, Microsoft won't let you see, tip you "sorry boy, please tolist?"

CodePudding user response:

Which the official name of the called "visual debugger" - the goal is to make you see, for example you can extend an own Image visual debugger, can extend a json visual debugger (show jsonTree, for example, when you write json to have the tree, but the somebody else to show you, can take the tree display, you see only the somebody else want to show, isn't he in fact run)

CodePudding user response:

Regardless of the opinions 1 or 2,
As long as you go to see, when they are IQueryable , that is not executed,
When they are IEnumerable When it is carried out,

CodePudding user response:

Thank you for your

CodePudding user response:


https://blog.csdn.net/ma_jiang/article/details/53065809

This is the ans programmer to extend the vs bring visual editor, you see he post code, as XXXX of XXXX, namely is to tell you, this can edit internal code, the code to execute, so he is to show a linq, can go to the show as a result, of course can also be generated to show the expression tree (ps: this kind of display generated linq expression trees of the third party visual editor actually have long, just not too common, I already forgot to call what)

CodePudding user response:

refer to 6th floor wanghui0380 response:
to
https://blog.csdn.net/ma_jiang/article/details/53065809

This is the ans programmer to extend the vs bring visual editor, you see he post code, as XXXX of XXXX, namely is to tell you, this can edit internal code, the code to execute, so he is to show a linq, can go to the show as a result, of course can also be generated to show the expression tree (ps: this kind of display generated linq expression trees third party visual editor actually have long, just not too common, I already forgot to call what)

Thank you for your brother a detailed reply

CodePudding user response:

The simplest is to enable database followed, debugging code, look at what specific database SQL,

CodePudding user response:

reference rain stopped reply on the eighth floor:
the simplest is to enable database to track, debugging code, look at what specific database SQL,

Is SQL server, SQL server Profiler, isn't it?

CodePudding user response:

references 9 f CCDDzclxy response:
Quote: refer to the eighth floor of the rain stopped reply:

The simplest is to enable the database to track, debug code, look at what specific database SQL,

Is SQL server, SQL server Profiler, isn't it?

yes

CodePudding user response:

IQueryable is delayed...

CodePudding user response:

Breakpoint sqlprofiler surveillance

CodePudding user response:

Add the monitor to see execution plan, two time more,
  •  Tags:  
  • LINQ
  • Related