Skip to content

Support Dapper FK POCO  #10

@shps951023

Description

@shps951023

e.g

    [Table("Report")]
    public class Report
    {
        [Key]
        public string Id { get; set; }
        public string Name { get; set; }
        public string Type { get; set; }
        public string Sql { get; set; }
        public string Updatetime { get; set; }
        public string ReportDataBaseId { get; set; }

        public ReportDataBase ReportDataBase { get; set; }
    }

    [Table("ReportDataBase")]
    public class ReportDataBase
    {
        [Key]
        public string Id { get; set; }
        public string Name { get; set; }
        public string DbType { get; set; }
        public string ConnectionString { get; set; }
    }

Query by

	var sql = "SELECT * FROM Report A left JOIN ReportDataBase B on A.ReportDataBaseId = B.ID";
	var result = Connection.Query<Report, ReportDataBase, Report>(sql,
	(b, a) => { b.ReportDataBase = a; return b; });

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions