Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var objemp = new List<EmployeeModel>(); 
EFClass objEFClass = new EFClass();

objemp = objEFClass.Model.ToList(); <-- "I am getting error in this line"


What I have tried:

I have changed the line to foreach block like

foreach(var obj in objEFClass.Model)
{
    objemp.Add(obj.Model);
}


But i am getting same error as described above. Please let me know where i am going wrong.
Posted
Comments
Karthik_Mahalingam 13-Nov-17 2:18am    
the Model type is not EmployeeModel, You cannot assign from one type to another. use var instead,
var objemp = new List<EmployeeModel>(); 
EFClass objEFClass = new EFClass(); 
var objemp = objEFClass.Model.ToList();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900