This is my method which gives me error.
public List GetProjectForCombo()
{
using (MyDataContext db = new MyDataContext (DBHelper.GetConnect
Method can not return anonymous type. It has to be same as the type defined in method return type. Check the signature of GetProjectForCombo and see what return type you have specified.
Create a class ProjectInfo with required properties and then in new expression create object of ProjectInfo type.
class ProjectInfo
{
public string Name {get; set; }
public long Id {get; set; }
}
public List GetProjectForCombo()
{
using (MyDataContext db = new MyDataContext (DBHelper.GetConnectionString()))
{
var query = from pro in db.Projects
select new ProjectInfo(){ Name = pro.ProjectName, Id = pro.ProjectId };
return query.ToList();
}
}