suppose your Department class is something
public class department
{
public int DepartmentId { get; set; }
public string DepartmentName { get; set; }
}
then you need to write your query like this...
public List<Department> getDeptNames()
{
using (RailwayElectricBillingDBEntities context = new RailwayElectricBillingDBEntities())
{
List<Department> dic = (from p in context.Departments
select new Department
{
DepartmentId = p.DepartmentId,
DepartmentName = p.DepartmentName
}
).ToList();
return obj;
}
}