Question

i recently started using petapoco ORM and came across a scenario where i had to execute a join query. As far as I know if the data isnt specific to one table then the type that can be used as dynamic as shown below:

var newsTitles = db.Query<dynamic>(@"SELECT Jobs.JobID, Branches.BranchName,
   Positions.PositionName, Jobs.YearsOfExperience, Jobs.Qualifications, 
   Jobs.Role, Jobs.ExpireyDate 
   FROM Branches 
   INNER JOIN Jobs ON Branches.BranchID = Jobs.Branch 
   INNER JOIN Positions ON Jobs.Position = Positions.PositionID");

please let me know if I approached the problem correctly

my question is how can iterate though the returned results in code? Many thanks

Était-ce utile?

La solution

Yes, you approached the problem correctly.

You can iterate over the results in the same way you iterate any List in .net

 foreach (var item in newsTitles ) {
     // do your thing
 }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top