TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
537
2.4k
597.1k
how to select two columns from DBContext linq c#?
Feb 17 2017 3:55 AM
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<PartnerOffice> 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<PartnerOffice>();
}
}
I have tried this also,
Here compile time error occurred.
public
List<PartnerOffice> ShowOfficesList()
{
using
(var context =
new
ReboxEntities())
{
return
context.PartnerOffices.Select(c =>
new
{ c.idPartnerOffice, c.Officename }).ToList();
}
}
Please help me...
Reply
Answers (
2
)
How to use Server.MapPath to go two folder using for loop?
Below are codes in c# and vb.net