I have an entity like this
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public int Id { get; set; }
}
And have a stored procedure as
CREATE PROCEDURE [dbo].[GetPersons]
AS
SELECT Id,FirstName FROM [dbo].[Persons]
When I call this stored procedure in My DbContext
var dataResult1 = dbContext.SqlQuery<Person>("[dbo].[GetPersons]");
The data reader is incompatible with the specified '..'. A member of the type, 'LastName', does not have a corresponding column in the data reader with the same name
I know if I define a new entity that has Id
, FirstName
and map stored procedure result to it everything is worke.
Now is there any way that I map my stored procedure result to Person Entity without define a new entity?