|
Dim dt1 as DateTime=CDate("08/08/2014")
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)
.sum1 =(From t2 in t.chld.AsQueryable.Where(Function(t2) t2.date1<dt1).Select(Function(t3) t3.quantity).DefaultIfEmpty
}).ToList
and after :
For Each l In list1
l.Parent.vls=l.sum1
Next
After the Tolist , all List1's : .Parent , .chl , .sum1 are in memory ? (That's the book's say about the .ToList , or show me an article that say the opposite ).
So now the following , For...each is run on memory ? Or I'm wrong ?
Thank you !
|
|
|
|
|
Hello !
This is my last question :
I don't know why , but this is working :
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
<NotMapped> Public Property vls As integer
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
Public Class PseudoMyObj
Inherits MyObj
End Class
Now on my form, I have this code :
Dim dt1 as DateTime=CDate("08/08/2014")
Dim list1 = (From t In context.MyObj Select New With { _
.Parent = New PseudoMyObj With { _
.chld = (From t2 in t.chld.AsQueryable.Where(Function(t3) t3.Date1>=dt1) Select t2), _
.vls=(t.chld.AsQueryable.Where(Function(t2) t2.date1<dt1).Select(Function(t3) t3.quantity).DefaultIfEmpty.Sum()) _
}).ToList
dim mylist as IEnumerable(of MyObj)=list1.Select(Function(t2) t2.Parent)
Please , I want your opinion , do you see anything wrong with this code ?
Thank you !
|
|
|
|
|
I already told you why it works. Your first query, and the sub-queries, on the database engine.
Getting the SQL query statement from the debugger and examining it in Notepad or in SQL Server Manager would have told you that.
Your second query, the last statement in your post, is executed client-side, not on the database engine.
I'm not telling you these things, like the above technique, because I like hearing myself type this crap. I tell you these things because this is how I debug and examine the functionality of EF.
Have a nice life.
|
|
|
|
|
Hi, i have 3 radiobutton, and 3 groupboxes, what im trying to do is when you chose one radiobutton, it will display a groupbox.
what i have(doesnt work), for each radiobutton is :
if radiobutton.checked then
groupbox1.visible = true
groupbox2.visible = False
groupbox3.visible = False
else
end if
|
|
|
|
|
I have to say that the user interface sound a bit odd if controls are shown or hidden based on radio buttons.
Anyhow, can you simply use (without any if)
groupbox1.Visible = radiobutton1.Checked
groupbox2.Visible = radiobutton2.Checked
groupbox3.Visible = radiobutton3.Checked
|
|
|
|
|
right, but which sub a insert that in ?
|
|
|
|
|
Use the CheckedChanged[^] event for the radio buttons. Since the code is the same for all radio buttons you can wire all the three events into the same event handler.
|
|
|
|
|
'After I make a selection in C1 I want C1T2 to enable, and then after selection in C1C2 it enables C1C3.
Private Sub Eval_CSet()
Dim t1 As String = ddlC1T1.Text
Dim t2 As String = ddlC1T2.Text
Dim t3 As String = ddlC1T3.Text
Dim c1 As String = ddlC1.Text
Dim c2 As String = ddlC2.Text
Dim c3 As String = ddlC3.Text
Try
'C1
If ddlC1.SelectedItem IsNot "" Then
Me.ddlC1.Items.Clear()
Me.ddlC1T1.Items.Clear()
Me.ddlC1T2.Items.Clear()
Me.ddlC1T3.Items.Clear()
'or ddlC1.SelectedIndex = -1
Me.ddlC2.Items.Clear()
Me.ddlC3.Items.Clear()
ddlC1T1.Enabled = False
ddlC1T2.Enabled = False
ddlC1T3.Enabled = False
Else
ddlC1T1.Enabled = True
ddlC1T2.Enabled = False
ddlC1T3.Enabled = False
End If
'Also tried
'If t1.Count > 0 Then
' ddlC1T2.Enabled = True
' ddlC1T3.Enabled = False
'Else
' ddlC1T2.Enabled = False
' ddlC1T3.Enabled = False
'End If
'If t2.Count > 0 Then
' ddlC1T3.Enabled = True
'Else
' ddlC1T3.Enabled = False
'End If
'Also tried
''C2
'If c2.ToString <> "" Then
' ddlC2T1.Enabled = True
' ddlC2T1.Enabled = False
'Else
' ddlC2T1.Enabled = False
'End If
Catch ex As Exception
Throw ex
End Try
End Sub
|
|
|
|
|
Bluewolf31 wrote: After I make a selection in C1 There's an event on the combobox that gets fired when the selection changes. That is the place where you'd enable/disable the other combo's.
I'd also recommend to remove the exception-handling; all it does it catch and rethrow.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That is the way I had it through the selection changes, and it was working but boss wants it done through a private sub all in one location, and now it wont work. Any suggestions?
|
|
|
|
|
I got it : )
changed it to:
If ddlCT1 Is "" Then
Now it functions perfectly.
|
|
|
|
|
It is preferred to have the code in one place, as it makes stuff easier to locate.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I have a FlexGrid control in which i make data entry and when i click on save command button it saves that data to a sequential file. Now my problem is that in another form, I want the user to edit any cell in the FlexGrid and that entry must replace the corresponding entry in the sequential file. But it is appending in the file, inspite of replacing the value that is edited.
|
|
|
|
|
Sequential files are tricky: they are called sequential because you cannot change the contents in an aribitrary location in the file.
The only solution using sequential files is to
1) create a new temporary file (in Output so you don't accidentally append to an existing file)
2) append the old data into the new file until you reach the point which the changed data
3) write the new data
4) resume appending the remaining data (take care to skip the changed ones before resuming copy)
The other solution requires you to use Random Access Files and to devise another way of memorizing the data.
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
|
|
|
|
|
|
Hello !
Is possible to use a global variable in a class like this :
Module Module1
....
Public v1 as integer
....
End Module
......
Public Class cl1
....
Public ReadOnly Property quantity As Integer
Get
return v1+.....-....... - So some calculations that use v1
End Get
End Property
....
End class
Is this possible ?
Thank you !
|
|
|
|
|
Yes it is possible if the variable is in a module - but it is not a good idea.
(Read up on race conditions for why)
|
|
|
|
|
I need a way to show a date with the difference between local time and GMT (Zulu) using VB 6.
The format has to be cccc-mm-dd hh.mm:ss +-hh.mmZ
For example, here in AZ we are GMT - 7.00 so 9:00 am would be 2015-09-16 09.00.00 -7.00Z
Does anyone know how I can do this?
Thanks.
Murray
|
|
|
|
|
Better put on your asbestos suit. VB 6 is not well liked around here.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Well, I like it and use it I'll devise an answer in the meantime.
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
|
|
|
|
|
I know, I know.
It's a mystery to me that people get so het up about what tool they like.
As if anyone really cares.
Every language I know and use has good and bad features.
Our job as programmers is to choose the best fit to the current task-and if that task is maintaining VB 6 code then ...
Murray
|
|
|
|
|
I have found a module to this address http://www.vbrad.com/article.aspx?id=62[^] which finely solves the time zones problems, I use this in production code daily (it has been used in my company for years).
I hope that helps you too.
Geek code v 3.12
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
|
|
|
|
|
And, despite the people that decry VB6, it IS still used in many organizations and STILL needs to be maintained.
Can it be rewritten in a newer language? Yes.
Is there a cost? Yes.
Is there justification. Not always.
Ask the financial industry how many applications are still written in COBOL and why...
|
|
|
|
|
That solved my problem!!
Many thanks.
Murray
|
|
|
|
|
Hello
I am new to this platform and my hope is I do that at right place. I had found Mark Regal's ,article named Deconstruction of a VBA Code Module. I am facing trouble making it work.
I have an MS-Access 2002 application which I want to parse my applocation's by code using provided module by Mark. According to the usage instructions to run it the IDE should be a later version then 2002 to support the functionality. Therefore I opened that Access 2002 MDB file on MS-Access 2010 and had imported his module into my project.
Now I stacked and I can't make it work. do I miss anything? Is the code exclusive to be used with MS-Excel?
Can anyone provide me the steps to make this work?
Thanks for any provided answer.
ruvain
|
|
|
|