LINQ query into ObservableCollection?

后端 未结 2 1515
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 04:12

Cast LINQ result to ObservableCollection

Jon Skeet give a great answer in the question ,but I still cannot make my own.

Still new to classes, so I am still i

2条回答
  •  走了就别回头了
    2021-01-19 05:09

    Basically, you need to pass IEnumerable result of the actual query to the database to initialize the ObservableCollection :

    var linqResults = sql.Staff_Time_TBLs
                         .Where(staff => staff.Staff_No == SelectedEmployee.Key &&
                                         staff.Date_Data == filterFrom &&
                                         staff.Date_Data == filterTo);
    
    var observable = new ObservableCollection(linqResults);
    

提交回复
热议问题