How to execute LINQ query to DataTable in C# .NET 3.5?
Hello everyone! I'm a beginner C# developer working with .NET Framework 3.5. I have a DataTable filled with data from the database. I need to filter rows by condition and get a list of objects. For example, there is an Employees table with columns ID, Name, Department, Salary. I want to select all employees from the "IT" department with a salary above 50000.
I tried writing like this:
\nDataTable dt = GetEmployeesDataTable();\nvar result = from row in dt.Rows\n where row["Department"] == "IT" && (int)row["Salary"] > 50000\n select row;\n\n\nBut I get a compilation error: "Could not find an implementation of the query pattern for source type 'DataRowCollection'. 'Where' not
No answers yet.
Log in to leave an answer