x.EmployeeName...." />
If you're happy to retrieve all the data and then perform the "except", that's relatively easy: return context. Employees . Where(x => x.EmployeeName.
Contains(keyword) && x. EmployeeTypeId == employeeeTypeId) // Limit the data *somewhat* . Take(count + BadEmployees.
Count) // Do the rest of the query in-process .AsEnumerable() . Except(BadEmployees) . Take(count) .ToList() Alternatively: I'm making some assumptions about property names here... var badEmployeeIds = badEmployees.
Select(x => x. EmployeeId) .ToList(); return context. Employees .
Where(x => x.EmployeeName. Contains(keyword) && x. EmployeeTypeId == employeeeTypeId) &&!badEmployeeIds.
Contains(x. EmployeeId)) . Take(count) .ToList().
If you're happy to retrieve all the data and then perform the "except", that's relatively easy: return context. Employees . Where(x => x.EmployeeName.
Contains(keyword) && x. EmployeeTypeId == employeeeTypeId) // Limit the data *somewhat* . Take(count + BadEmployees.
Count) // Do the rest of the query in-process .AsEnumerable() . Except(BadEmployees) . Take(count) .ToList(); Alternatively: // I'm making some assumptions about property names here... var badEmployeeIds = badEmployees.
Select(x => x. EmployeeId) .ToList(); return context. Employees .
Where(x => x.EmployeeName. Contains(keyword) && x. EmployeeTypeId == employeeeTypeId) &&!badEmployeeIds.
Contains(x. EmployeeId)) . Take(count) .ToList().
The Except method does a comparison, so it has to know how to compare the objects. For simple types there are standard comparisons, but for complex types you need to supply an equality comparer that compares the relevant data in the object. Example: class EmployeeComparer : IEqualityComparer { public bool Equals(Employeees x, Employeees y) { return x.Id == y.
Id; } public int GetHashCode(Employeees employee) { return employee.Id.GetHashCode(); } } Usage: return context. Employeees . Where(x => x.EmployeeeName.
Contains(keyword) && x. EmployeeeTypeId == employeeeTypeId) . Except(BadEmployeees, new EmployeeComparer()) .
Take(count) .ToList().
I used your class and used it like this: context.Employees. Where(x => x.EmployeeName. Contains(keyword) && x.
EmployeeTypeId == EmployeeTypeId). Except(Employees,new EmployeeComparer()). Take(count).ToList(); but I got this error: LINQ to Entities does not recognize the method 'System.Linq.
IQueryable`1ManUp.Data. Employee ExceptEmployee(System.Linq. IQueryable`1ManUp.Data.
Employee, System.Collections.Generic. IEnumerable`1Data. Employee, System.Collections.Generic.
IEqualityComparer`1Data. Employee)' method, and this method cannot be translated into a store expression. – Amr ElGarhy Aug 17 at 22:35 Amr ElGarhy: I see.
You would need a .AsEnumerable() before that to pull the result from the database. If you want to do the work in the database, you should do it with a join instead. – Guffa Aug 17 at 23:30 yes, at first I wanted to do with join but I am not an expert in linq so couldn't write it, can you give an example for this join in my case?
– Amr ElGarhy Aug 18 at 1:40.
Next, I set up the context of the window to the newly discovered model and proceed with a creation of Rx-based timer, which every second fires off an event causing a randomized Customer to be created and added to the collection, using model's public Add() method. The AOP's DispatchMethod attribute simply allows for the update of the UI to be executed from a background thread. Otherwise, WPF would generate an exception if the method was not executed on the GUI thread.
To expose the dynamic collection of customers, I opted to use a simple ListBox, with a DataTemplate. Following the SOLID principles of OO desing I leave it up to the data consumer to sort the collection of Customers as needed. There are many controls out there, like Telerik or Infragistics, which will also allow for additional functionality, for example filtering, or data virtualization.
So exposing the collection as IQueryable makes sense IMHO. And that's pretty much all it takes to have a multithreaded observable collection exposed in WPF. Enjoy the attached code and submit your comments.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.