I am stuck on a type matching problem. I started by ensuring that my syntax was correct by checking it against the following:
Proper Join/GroupJoin implementation
I tried to substitute for all of my conditions, and noticed that my types didn't match. Here is my code:
var waQ = someRepository.GetAllQ();
var wrQ = someOtherRepository.GetAllQ();
query = waQ
.GroupJoin(wrQ,
wa => new { wa.someInt, wa.someNullableInt },
wr => new { wr.someMatchingInt, wr.someNonNullableInt },
(wa, wr) => new { wa,
reqOrderID = wr.FirstOrDefault().someMatchingInt,
reqWorkerID = wr.FirstOrDefault().someNonNullableInt
})
.Select([etc.]);
The error that I am getting, specifically, is that the type arguments cannot be inferred from the usage. I believe the underlying error is that I can't match the nullable int to the non-nullable int.
However, I am hard pressed to find workarounds. I tried casting the non-nullable int "as int?" and I got this error:
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
I also tried (int?) and tried casting them both as strings (.ToString()). No luck.
Does anyone have any suggestions?
Before you suggest it, I am not allowed to go and make wa.someNullableInt non-nullable, nor would it make sense for the program.
Thanks in advance for any help!