0

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?

How can I map the results of a sql query onto objects?

1 Answers1

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