Click here to Skip to main content
15,915,873 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Port data from MS Word to SQL Server Pin
Member 959774823-Feb-15 2:58
Member 959774823-Feb-15 2:58 
QuestionForm manipulation via VBS - need form to update after 1st selection Pin
Member 1146779320-Feb-15 10:45
Member 1146779320-Feb-15 10:45 
QuestionWhy this query produce wrong results ? Pin
dilkonika20-Feb-15 6:46
dilkonika20-Feb-15 6:46 
AnswerRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 9:39
mveDave Kreskowiak20-Feb-15 9:39 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika20-Feb-15 9:45
dilkonika20-Feb-15 9:45 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 10:56
mveDave Kreskowiak20-Feb-15 10:56 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika20-Feb-15 11:10
dilkonika20-Feb-15 11:10 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 12:37
mveDave Kreskowiak20-Feb-15 12:37 
The concept is called "deferred execution". Your query isn't actually run until the code gets to the call to .ToList().

The reason why the vls property is 0 is because your property getter is not part of the query that re-hydrates the objects. That code isn't run until you call the property from some other code. I already told you why that property is returning 0. Because the objects it's working with don't exist yet.

Your original query never re-hydrated the chld objects, so the vls property didn't have anything to work with. That's why you need the .Includes().

It works if the code is part of the query because it gets baked into the SQL that is sent to the database. Again, you can SEE THIS by following the technique I told you about before. Get the SQL SELECT statement and paste it into a query window or into Notepad and READ IT.


Do you actually read any of the links we post? They would help you to understand what's going on in EF because you don't seem to have a grasp of it yet. Seriously, before you waste a ton of time whould why things are working, pickup the Programming Entity Framework and/or the Code First books by Julie Lerman and read them.
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Why this query produce wrong results ? Pin
dilkonika20-Feb-15 12:47
dilkonika20-Feb-15 12:47 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 14:23
mveDave Kreskowiak20-Feb-15 14:23 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika20-Feb-15 14:30
dilkonika20-Feb-15 14:30 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 16:38
mveDave Kreskowiak20-Feb-15 16:38 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika20-Feb-15 17:01
dilkonika20-Feb-15 17:01 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak20-Feb-15 17:54
mveDave Kreskowiak20-Feb-15 17:54 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 5:27
dilkonika21-Feb-15 5:27 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak21-Feb-15 7:35
mveDave Kreskowiak21-Feb-15 7:35 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 7:53
dilkonika21-Feb-15 7:53 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak21-Feb-15 8:01
mveDave Kreskowiak21-Feb-15 8:01 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 8:05
dilkonika21-Feb-15 8:05 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak21-Feb-15 12:59
mveDave Kreskowiak21-Feb-15 12:59 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 14:32
dilkonika21-Feb-15 14:32 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak21-Feb-15 15:38
mveDave Kreskowiak21-Feb-15 15:38 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 16:00
dilkonika21-Feb-15 16:00 
GeneralRe: Why this query produce wrong results ? Pin
Dave Kreskowiak21-Feb-15 16:44
mveDave Kreskowiak21-Feb-15 16:44 
GeneralRe: Why this query produce wrong results ? Pin
dilkonika21-Feb-15 16:52
dilkonika21-Feb-15 16:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.