Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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

PREVIOUS NEXT
Code Example
Csharp :: C# create delegate type at runtime 
Csharp :: download file c# 
Csharp :: create star rating using loop in c# 
Csharp :: go down a line in function documentation 
Csharp :: c# psobject get value 
Csharp :: grass download for unityh 
Csharp :: c# check if object can be cast to type 
Csharp :: upcasting and downcasting in c# 
Csharp :: sqldatareader get row count 
Csharp :: c# inline 
Csharp :: unity predicts rigidbody position in x seconds 
Csharp :: unity recttransform set anchor 
Csharp :: remove tag anchor and inside tag from html raw text c# 
Csharp :: c# stack 
Csharp :: Get the current culture in a controller asp.net-core 6 
Csharp :: convert string to boolean c# 
Csharp :: unity transform.translate 
Csharp :: c# windows service .net core 
Csharp :: unity overlapcircle 
Csharp :: how to add default value to combobox in wpf 
Csharp :: c# get pixel from bitmap click 
Csharp :: hydrogen fuels 
Csharp :: block nulltarge tpl dataflow 
Csharp :: population of the world 
Html :: blank space html 
Html :: bootstrap css cdn 
Html :: html disable drag image 
Html :: center vertically and horizontally bootstrap 4 
Html :: how to show iframe in full width 
Html :: import font awesome 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =