I'm converting the Linq query below from C# to VB.Net. Can you spot my error? The query joins 3 XML datasets. Thanks in advance!
C# - This one works great.
List<Course> courses =
(from course in CourseXML.Descendants(ns + "row")
join coursecategory in CourseCategoryXML.Descendants("Table") on (string)course.Attribute("code") equals (string)coursecategory.Element("DATA")
join category in CategoryXML.Descendants("Table") on (string)coursecategory.Element("GRP") equals (string)category.Element("GRP")
where (string)coursecategory.Element("RECTYPE") == "C"
select new Course {
CategoryCode = category.Element("GRP").Value,
Code = course.Attribute("code").Value
}).ToList<Course>();
VB - I'm getting no results from this, so I suspect I'm either casting improperly or joining improperly.
Dim result = (From course In CourseXML.Descendants(ns + "row") _
Join coursecategory In CourseCategoryXML.Descendants("Table") On CType(course.Attribute("code"), String) Equals CType(coursecategory.Element("DATA"), String) _
Join category In CategoryXML.Descendants("Table") On CType(coursecategory.Element("GRP"), String) Equals CType(category.Element("GRP"), String) _
Where CType(coursecategory.Element("RECTYPE"), String) = "C" _
Select New Course() With _
{ _
.CategoryCode = category.Element("GRP").Value, _
.Code = course.Attribute("code").Value _
}).ToList()