This is my method which gives me error.
public List<Project> GetProjectForCombo()
{
using (MyDataContext db = new MyDataContext (DBHelper.GetConnectionString()))
{
var query = from pro in db.Projects
select new { pro.ProjectName, pro.ProjectId };
return query.ToList();
}
}
If i change it with this:
public List<Project> GetProjectForCombo()
{
using (MyDataContext db = new MyDataContext (DBHelper.GetConnectionString()))
{
var query = from pro in db.Projects
select pro;
return query.ToList();
}
}
Then it works fine with no errors.
Can you please let me know that how I can return only ProjectId
and ProjectNam
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…