Click here to Skip to main content
15,890,690 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Port data from MS Word to SQL Server Pin
Richard MacCutchan23-Feb-15 0:00
mveRichard MacCutchan23-Feb-15 0:00 
GeneralRe: Port data from MS Word to SQL Server Pin
Member 959774823-Feb-15 2:57
Member 959774823-Feb-15 2:57 
GeneralRe: Port data from MS Word to SQL Server Pin
Richard MacCutchan23-Feb-15 3:20
mveRichard MacCutchan23-Feb-15 3:20 
GeneralRe: Port data from MS Word to SQL Server Pin
Member 959774826-Feb-15 22:29
Member 959774826-Feb-15 22:29 
GeneralRe: Port data from MS Word to SQL Server Pin
Chris Quinn23-Feb-15 0:21
Chris Quinn23-Feb-15 0:21 
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 
Hello !

I'm using Entity Framework6 with VB.net and SQL server 2008R2.

I have this case :

This is my model :

Partial Public Class Myobj
      Public Property id As Integer
      Public property name as string
      Public Overridable Property chld As ICollection(Of chld) = New HashSet(Of chld) 
   End Class


 Partial Public Class Myobj
     Public shared cond1 as DateTime
      <NotMapped> Public ReadOnly Property vls As integer
      Get
            Return chld.AsQueryable.Where(Function(t2) t2.date1<cond1).Select(Function(t3) t3.quantity).DefaultIfEmpty.Sum()
      End Get
End Property
End Class


Partial Public Class chld
    Public Property id As Integer
    Public Property date1 as DateTime
    Public Property quantity as Integer
    Public Property ParentID as integer
    Public Overridable Property MyObj1 As MyObj
End Class 


Now on my form, I have this code :

SQL
Dim dt1 as DateTime=CDate("08/08/2014")
Myobj.cond1=dt1

 Dim list1 = (From t In context.MyObj Select New With { _
      .Parent = t, _
      .chl =  (From t2 In t.chld.AsQueryable.Where(Function(t3) t3.Date1>=dt1) Select t2)
}).ToList


This query always produces 0 in vls property for each item in Myobj1.( !! but it's not true according to data in database!!).

Why this query product a such result?

Thank you!

modified 20-Feb-15 15:38pm.

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 
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 

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.