S
Shan1986
Guest
Hallo,
I have following class setup
Property ID serves as a primary key for the object, each class has its own primary key .I know all the primary keys and i want to find the HomeLandline number by using the primary keys.
Class Person
Public Property IDp() As Integer
Public Property FirstName() as String
Public Property LastName() as String
Public Property Contact() as Contact
End Class
Class Contact
Public Property IDc() As Integer
Public Property Country() as String
Public Property City() as String
Public Property Street() as String
Public Property Email() as Email
Public Property Phone() as Phone
End Class
Class Email
Public Property IDe() As Integer
Public Property WorkEmail() as String
Public Property PersonalEmail1() as String
Public Property PersonalEmail2() as String
End Class
Class Phone
Public Property IDp() As Integer
Public Property WorkPhone() as String
Public Property WorkMobile() as String
Public Property PersonalMobile() as String
Public Property HomeLandline() as String
End Class
I have people bindinglist and using following code and it works . Can it be further simplified or any other way? Thanks
Dim indexPerson = People.IndexOf(People.Where(Function(x) x.ID= Me.IDp).FirstOrDefault)
Dim ContactList = People.Item(indexPerson).Contact.ToList
Dim indexContact = ContactList .IndexOf(ContactList .Where(Function(x) x.ID = Me.IDc).FirstOrDefault)
Dim PhoneList = ContactList.Item(indexContact).Phone.ToList
Dim indexPhone = PhoneList.IndexOf(PhoneList.Where(Function(x) x.ID = Me.IDp).FirstOrDefault)
dim Phonenr as String = PhoneList.Item(indexPhone).HomeLandline.ToString
Thanks
Continue reading...
I have following class setup
Property ID serves as a primary key for the object, each class has its own primary key .I know all the primary keys and i want to find the HomeLandline number by using the primary keys.
Class Person
Public Property IDp() As Integer
Public Property FirstName() as String
Public Property LastName() as String
Public Property Contact() as Contact
End Class
Class Contact
Public Property IDc() As Integer
Public Property Country() as String
Public Property City() as String
Public Property Street() as String
Public Property Email() as Email
Public Property Phone() as Phone
End Class
Class Email
Public Property IDe() As Integer
Public Property WorkEmail() as String
Public Property PersonalEmail1() as String
Public Property PersonalEmail2() as String
End Class
Class Phone
Public Property IDp() As Integer
Public Property WorkPhone() as String
Public Property WorkMobile() as String
Public Property PersonalMobile() as String
Public Property HomeLandline() as String
End Class
I have people bindinglist and using following code and it works . Can it be further simplified or any other way? Thanks
Dim indexPerson = People.IndexOf(People.Where(Function(x) x.ID= Me.IDp).FirstOrDefault)
Dim ContactList = People.Item(indexPerson).Contact.ToList
Dim indexContact = ContactList .IndexOf(ContactList .Where(Function(x) x.ID = Me.IDc).FirstOrDefault)
Dim PhoneList = ContactList.Item(indexContact).Phone.ToList
Dim indexPhone = PhoneList.IndexOf(PhoneList.Where(Function(x) x.ID = Me.IDp).FirstOrDefault)
dim Phonenr as String = PhoneList.Item(indexPhone).HomeLandline.ToString
Thanks
Continue reading...