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 linq or lambda. I would like to do something like this:
using (var context = new FootballTableContext())
{
var players = context.Database.SqlQuery<PlayerViewModel>("SELECT Vardas, Pavarde FROM ZAIDEJAS").ToList();
}
but after executing this code, I Get a list of PlayerViewModel with null values.
ViewModel class:
public class PlayerViewModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
Context class:
public class FootballTableContext : DbContext
{
public FootballTableContext() : base("DefaultConnection") { }
}
So my question is how to bind that query to my ViewModel?