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
Basically, you need to pass IEnumerable<Staff_Time_TBL>
result of the actual query to the database to initialize the ObservableCollection<Staff_Time_TBL>
:
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<Staff_Time_TBL>(linqResults);
You need ObservableComputations. Using this library you can code like this:
var linqResults = sql.Staff_Time_TBLs
.Filtering(staff =>
staff.Date_Data > fromDate &&
staff.Date_Data < toDate &&
staff.Staff_No == employeeNumber);
In code above I assumed sql.Staff_Time_TBLs is ObservableCollection. linqResults is ObservableCollection and reflects all the changes in the sql.Staff_Time_TBLs collection and properties mentioned in the code. Ensure that all properties mentioned in the code above notify of changes through the INotifyPropertyChanged interface.