Filling one to many relationship using using Dapper or via Linq
问题 Entity - AllSalesTerritory contains List<MySalesPerson> representing one to many relationship. I have Sql query to fetch the data where the two entities are mapped using a column TerritoryId . I use a following code to fill the entity using Dapper micro ORM : List<AllSalesTerritory> allSalesTerrotories = _connection.Query<AllSalesTerritory, MySalesPerson, AllSalesTerritory> (query, (pd, pp) => { pd.SalesPersons.Add(pp); return pd; }, splitOn: "BusinessEntityId") .ToList(); BusinessEntityId is