BYG
BYG

Reputation: 35

When using the multi-mapping APIs ensure you set the splitOn param if you have keys other than Id

I keep on getting this error. The place where it's throwing the error is:

 var projectManagerList = gridReader.Read<ProjectResources, Employee, ProjectResources>((pr, e) =>
                    {
                        pr.Employee = e;
                        return pr;
                    }).ToList();

The sql is:

 SELECT DISTINCT
                             p_Resources.Empl_ID as EmployeeId
                            ,p_Resources.cRole
                            ,p_Empl.ID as Id
                            ,p_Empl.Title
                            ,p_Empl.First_Name as FirstName
                            ,p_Empl.MI as MiddleInitial
                            ,p_Empl.Last_Name as LastName
                            ,p_Empl.Phone
                            ,p_Empl.PWD as Password
                            ,p_Empl.email as Email
                            ,p_Empl.LoginName
                            ,p_Empl.Admin
                      FROM   p_Empl
                         LEFT OUTER JOIN
                          p_Resources on p_Resources.Empl_ID = p_Empl.ID
                     WHERE  p_Resources.cRole='Project Manager' 

I wrote "as Id" so why is it throwing the error? Thanks.

Upvotes: 2

Views: 774

Answers (1)

Palle Due
Palle Due

Reputation: 6292

It tells you to set the splitOn parameter. So you should set it to Id.

var projectManagerList = gridReader.Read<ProjectResources, Employee, 
ProjectResources>((pr, e) =>
                {
                    pr.Employee = e;
                    return pr;
                },splitOn: "Id").ToList();

It tells you the split between ProjectResources and Employee is the Id column.

Upvotes: 1

Related Questions