Dapper 查询多个表,映身到对象的实例对象
public async Task<IEnumerable<SplitMergeOrderSourcePlanOrderView>> GetSplitMergeOrderSourcePlanOrderViewAsync(long splitMergeOrderId) { string sql = "select a.*,b.* from PlanOrderView a join SplitMergeOrderSource b on a.Id=b.PlanOrderId where a.Id in (select PlanOrderId from SplitMergeOrderSource where SplitMergeOrderId=@splitMergeOrderId)"; using var conn = _dapper.CreateConnection(); var result = await conn.QueryAsync<PlanOrderView, SplitMergeOrderSource, SplitMergeOrderSourcePlanOrderView>(sql.ToString(), (plan, source) => { var result = new SplitMergeOrderSourcePlanOrderView(); result.PlanOrderView = plan; result.SplitMergeOrderSource = source; return result; }, new { splitMergeOrderId }); return result; }