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
Adalat Khan
654
1.5k
864.6k
Retrieve specific fields from a database table using LINQ
Aug 14 2018 5:15 PM
I have an Action Method in MVC application that retrieves the list of Students from a database table StudentsInfo using LINQ query. When i retrieve all the columns from the table then the Query works but when i try to retrieve some specific columns from the table then i get the following error message:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[<>f__AnonymousType6`1[System.String]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MVCApplication.StudentsInfo]'.
What I have tried:
Following is the action Method
public ActionResult GetAllStudents()
{
//Retrieve data from StudentsInfo table
var result = from d in db.StudentsInfo
select new
{
d.StdRegNumber,
d.StdName,
d.StdDoBirth
};
return View(result.ToList());
}
Thanks in advance
Reply
Answers (
5
)
change database notification with using signalr linq
How do I get the huge data from web.api?