Say you have a simple query such as for example:
SELECT p.name, p.age, c.course, c.lecture
FROM person p, college c;
Can something like this be achieved in LINQ? the reason I am trying to list a whatever is in those columns and iterate over them.
Yes. It is called cross join:
var result = (from p in person
from c in college
select new { p.Name, p.Age, c.Course, c.Lecture });
In method syntax:
var result = person.SelectMany(p =>
college.Select(c => new { p.Name, p.Age, c.Course, c.Lecture });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With