Entity Framework bind raw SQL query to model class

前端 未结 1 943
别跟我提以往
别跟我提以往 2020-12-21 05:08

I got assignment to develop football table management system. I decided to do it using asp.net mvc. Only requirement is to use raw SQL queries. So that means I can\'t use li

相关标签:
1条回答
  • 2020-12-21 05:58

    Do it like this:

    var players = dbContext.Database
        .SqlQuery<PlayerViewModel>("SELECT Vardas as FirstName, Pavarde as LastName FROM ZAIDEJAS")
        .ToList<PlayerViewModel>();
    

    It is known as SQL queries for non-entity types.

    0 讨论(0)
提交回复
热议问题