Простое сопоставление Dapper

Таблица:

create table Documents 
   (Id int, 
    SomeText varchar(100), 
    CustomerId int, 
    CustomerName varchar(100)
   )

insert into Documents (Id, SomeText, CustomerId, CustomerName) 
   select 1, '1', 1, 'Name1' 
     union all
   select 2, '2', 2, 'Name2'

Классы:

public class Document
{
    public int Id { get; set; }
    public string SomeText { get; set; }
    public Customer { get; set; }
}

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Как я могу получить все Documentsс их Customersс помощью Dapper? Это дает мне все документы, но клиент нулевой (конечно):

connection.Query("select Id, SomeText, CustomerId, CustomerName from Documents")...

РЕДАКТИРОВАТЬ -аналогичный, но более сложный вопрос о сопоставлении:Промежуточное сопоставление Dapper

5
задан Community 23 May 2017 в 10:28
поделиться