Tuesday, 27 August 2013

Linq and Read data from another Class

Linq and Read data from another Class

1- I have a Data class :
public class Data
{
public static List<Employee> Employees = new List<Employee>
{
new Employee {EmployeeID=1, FirstName="Garth", LastName="Schulte",
Position="Trainer"},
new Employee {EmployeeID=2, FirstName="James", LastName="Conrad"
,Position="Trainer"}
};
}
2- In MainWindow.xmal.cs
private void GetEmployeeListQuery()
{
dynamic emps = from emp in Data.Employees
select emp;
lbEmployees.DataContext = emps;
}
I have error when reading the select emp:
XamlParseException occurred
'The invocation of the constructor on type 'WpfApplication1.MainWindow'
that matches the specified binding constraints threw an exception.' Line
number '3' and line position '5'.
Please, Advise me

No comments:

Post a Comment