Hello Everyone,
How can I select only two columns from the table via linq from
DBContext ?I have tried,
Here run time error occurred.
- public List
ShowOfficesList() - {
- using (var context = new ReboxEntities())
- {
- var listPartnerOfficeName = from offices in context.PartnerOffices select new PartnerOffice() { idPartnerOffice = offices.idPartnerOffice, Officename = offices.Officename };
- return listPartnerOfficeName.ToList
(); - }
- }
Here compile time error occurred.
- public List
ShowOfficesList() - {
- using (var context = new ReboxEntities())
- {
- return context.PartnerOffices.Select(c => new { c.idPartnerOffice, c.Officename }).ToList();
- }
- }

Tapan PatelPosted Feb 19, 2017, 3:44 PM
Amit GuptaPosted Feb 17, 2017, 5:04 AM