Answers for "how to select class object from query c#"

C#
0

how to select class object from query c#

class ProjectInfo
{
   public string Name {get; set; }
   public long Id {get; set; }
}

public List<ProjectInfo> 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();
    }
}
Posted by: Guest on December-16-2020

Code answers related to "how to select class object from query c#"

C# Answers by Framework

Browse Popular Code Answers by Language