Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

linq select to list

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();
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity how to check index of enum 
Csharp :: dotnet core encryption and decryption 
Csharp :: c# list object 
Csharp :: c# datagridview change column alignment 
Csharp :: c# subtract 24 hours form datetime 
Csharp :: c# return two values 
Csharp :: c# new object 
Csharp :: hide external app from taskbar 
Csharp :: open project in visual studio using command prompt 
Csharp :: c# get name of type 
Csharp :: save binary data to file c# 
Csharp :: list view in unity 
Csharp :: excel rows count 
Csharp :: loop in c# 
Csharp :: orderby c# 
Csharp :: inheritance 
Csharp :: Reporting Progress from Async Tasks c# 
Csharp :: linq while loop in c# 
Csharp :: unity fast sin 
Csharp :: unity android keycodes 
Csharp :: c# yes no cancel dialog with icons 
Csharp :: pass viewbag selectlistitem to razor 
Csharp :: custom attribute for auth permission check .net 
Csharp :: ASP.NET C# Catch all exceptions in a class 
Csharp :: C# dest 
Csharp :: edit database from datagridview with right click on data c# 
Csharp :: whining 
Csharp :: params string[] 
Csharp :: c# Lucene search - build index 
Csharp :: c# ienumerable unassigned 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =