Jump to content
Vb Samples For Download
4 replies to this topic
Posted 05 June 2011 - 09:04 AM
There has been very little demand for VB samples, but one unhappy VB developer is enough to justify doing it - it was just a matter of creating the time. I've converted a chunk of the samples that are now available from the download page at learnentityframework.com/downloads.
Posted 10 August 2011 - 12:14 PM
I develop in Visual Basic and I'm pretty use to seeing code samples in C# so I don't typically have problems understanding them. However, there is one code snippet in chapter 26th of the 2nd edition that I cannot for the life of me figure out. It's the GetStoredList method on page 765. I can't figure how how to cast a list as a List(Of T). No matter what I try the VB compiler doesn't like it. I'd love to see chapter 26 in VB.
Posted 04 February 2013 - 06:53 AM
Hi -- Like kstevens715 I also prefer VB.NET and can get by with C# but the issue in Chapter 26 that kstevens715 mentions has also tripped me up. Any idea on how to solve it? FYI, the code I'm using is here:
Private Function GetStoredList(Of T As Class)() As List(Of T) Dim typeName As String = GetType(T).Name Dim _list As List(Of T) = Nothing Select Case typeName Case "Activity" : _list = TryCast(_activities, List(Of Activity)) Case "Destination" : _list = TryCast(_destinations, List(Of Destination)) Case "Lodging" : _list = TryCast(_lodgings, List(Of Lodging)) Case Else Throw New NotSupportedException("You cannot make an UntrackedList from this type.") End Select Return _list End Function
And the compiler errors are as follows:
Help is greatly appreciated!
Posted 06 February 2013 - 08:11 AM
I just spent some time converting and then fixing up the VB soluiton until it finally worked. The method you pointed out (well both GetSortedList and SetSortedList) were the biggest problem. The converter couldn't figure it out nor could I. But someone actually asked about converting this same code from my book on Stackoverflow and someone else provided the solution! There was one other tough spot which was the expression passed in to the SortedList method. I finally figured out to change "object" to string and it worked!
I ran through the app, retrieving, editing and inserting records so I think it's really all working now.
Oh, I just added the solution to the downloads page on the website: http://learnentityfr.../downloads/#2ed
Thanks for the inspiration. Sorry for the trouble. I get about one "help with the VB' a year.
Posted 06 February 2013 - 08:49 AM
Thanks, Julie! Never would have thought of the CObj() solution.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users