I have a database with id columns like BookId, AuthorId etc. My code files, however, have the Id property. I am trying to convert parts of a program that use NHibernate with Dapper, so I am trying to eliminate the need for both the Id and the BookId property. NHibernate has a built-in ID card that maps the BookId to the Id property of Book objects and is similar to the AuthorId for the Id property in Author objects.
Is there any way to make this Dapper outside of providing an alias to a column in a sql query?
public class Book { public int Id { get; set; } public string Name { get; set; } } public class Author { public int Id { get; set; } public string Name { get; set; } }
An example request that I use looks like this:
select * from Books b inner join Author a on a.AuthorId = b.AuthorId
If Dapper doesn't support this easily, any thoughts on what other options I have?
source share