c# - Using LINQ to obtain dependencies of tasks stored in a table -
i have database has table following layout:
jobid taskid dependanttaskid -------------------------------- 1000 20 19 1000 21 20 as can see, specifies each job, , each task within job dependent task identifiers are. wanted write linq, given job returned each task , associated dependencies can sort appropriately. linq have:
var query = t in sys_jobdependanttasks t.jobid == 1000 select new { taskid = t.taskid, dependencies = (from d in sys_jobdependanttasks d.dependanttaskid == t.taskid select d.dependanttaskid).tolist() }; var result = query.tolist(); result.dump(); ... except results unexpected. get:
taskid dependencies ---------------------------- 9304 9304 9304 a raw dump of table however, says 9304 depends on 9633. pretty new linq, wondering if there obvious doing wrong?
i think need change sub query as:
from d in sys_jobdependanttasks d.taskid == t.dependanttaskid select d.taskid
Comments
Post a Comment