I am trying to add a left join to my Linq query as below;
var leftJoin = (from person in ISession.Query<Person>()
join cars in ISession.Query<Cars>()
on person.carGuid equals cars.Guid into gj
from subCar in gj.DefaultIfEmpty()
select new carDto
{
carBrand= subCar.carBrand,
ownerName = person.Name
}).toList();
I am getting this error; NHibernate.HibernateException: 'Query Source could not be identified: ItemName = gj, ItemType = System.Collections.Generic.IEnumerable`1
Is there a way to fix this? I need to add left outer join to my query
CodePudding user response:
Not 100% sure but we usually get this error when the dbSet/repository is not set, in your instance the ISession.Query<Person>(), can you check you are not getting a null reference there?
Other than that, this is the correct way to do the left join in Linq.
