1

How to change the following linq query to select another field value Field<int>("data_entry"),i want to select multiple fields .


 var a = DF_Utilities.GetAvailableTasks(empnum, 1).AsEnumerable().Where(
    p => p.Field<int>("task_code") == int.Parse(drpTasks.SelectedValue)).Select(p => p.Field<int>("cand_num")).First();

p.Field<int>("cand_num"),Field<int>("data_entry")

instead of p.Field<int>("cand_num")

4

1 回答 1

5

您可以使用匿名类型

var a = DF_Utilities.
    GetAvailableTasks(empnum, 1).
    AsEnumerable().
    Where(p => p.Field<int>("task_code") == int.Parse(drpTasks.SelectedValue)).
    Select(p => new 
    {
        candNum = p.Field<int>("cand_num"),
        dataEntry = p.Field<int>("data_entry")
    }).
    First();
于 2013-07-21T09:00:03.780 回答