Reputation: 1
I have a LINQ query which performs a LEFT JOIN on two tables:
var leftJoinData = (from costDetails in dbContext.CostDetails
join orderInformation in dbContext.OrderInformation on costDetails.FK_INVTABLEUID equals orderInformation.FK_INVTABLEUID
into completeInformationList
from ci in completeInformationList.DefaultIfEmpty()
select new
{
ci.OrderId,
cost = costDetails.MaximumRetailPrice
}).AsNoTracking().ToList();
I want to test the method executing this query, but when I test after mocking the db set(using Moq), I get System.ArgumentNullException : Value cannot be null. (Parameter 'source'). But when I remove the LEFT JOIN and instead perform and INNER JOIN, that is, when I remove the completeInformationList.DefaultIfEmpty() call, I am able to test it.
Upvotes: 0
Views: 67