in my wpf mvvm architecture I have 2 tables named department and employee.DepartmentId is the foreign key of Employee table. I am using stored procedure to getting data. The procedure is working fine and getting the details in sql management studio. My Storeed procedure is
Select * from Employee e inner join Department d on e.DepartmentId = d.departmentId
In my mvvm architecture the department name is not getting while selecting the employee details in the ObservableCollection in viewmodel.How can we get the DepartmentName in ObservableCollection in mvvm viewmodel.
My employee model Class is
public class Employee
{
public Employee()
{
this.Departments = new HashSet<Department>();
}
public long DepartmentId;
public long EmployeeId;
public string Name;
public virtual ICollection<Department> Departments { get; set; }
}
}
And My ObservableCollection in viewmodel is
public ObservableCollection<Employee> GetEmployeeList()
{
var result = from p in dc.sel_Employee().AsEnumerable()
select new
{
EmployeeId= p.EmployeeId,
Name = p.Name
};
return new ObservableCollection<Employee>(result);
}
The error showing is
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
Can anyone help.Thanks in advance.