How can I map the results of a SQL command into a class object in Net Core, with SqlCommand() or FromSql()? Can someone update this answer for Net Core, or is the syntax still the same?
Asked
Active
Viewed 1,488 times
0
-
What issue are you facing while using the approach suggested in that question? – Chetan Dec 03 '18 at 05:04
1 Answers
1
With EntityFramework Core, you simply use yourDbContextInstance.Set<T>().FromSql("your sql statement");
Where T
is your class.
However, your sql MUST return all the properties on your class.
See documentation for more details on this.

Gerald Chifanzwa
- 1,277
- 7
- 14