So I have been using Entity Framework since version 4 and recently had some breaking changes in a project I was doing. Suffice to say I am using EF to get the differential from one database to another in an ETL process with EF core 3.1.2 which was EF Core 2.2.6. The part that is now breaking has code similar to this.
var setOne = await 1stContext.table.Where(x => x.DateModified >= inputDate)).Select(x => new { x.UserId, x.RoleId, x.UniversityId }).ToListAsync();
var toRemove = 2ndContext.table.Where(x => setOne.Contains(new { x.UserId, x.RoleId, x.UniversityId })).ToList();
Having an anonymous projection 'new { (items) }' used to work but now it blows up. I tried casting to a named tuple that was new since C# 7 but you cannot do that in an expression tree according to the compiler. So any ideas on a new ways? Maybe just do a linq join or similar? My idea was always to do the where clause first before realizing the data so the equivalent sql would not give me all the results and then go over them.
UPDATE Here is a simple print screen without ef of what I mean. I did this all the time with very wide sets I wanted to only do a smaller set of and then find it. I could do a join but the key is if you look at my second statement I am not projecting to a real object with a 'toList' yet and if I did I would lose the ability to get the objects I wanted to remove potentially. I could possibly do a join but I just don't want to make expensive database calls to get everything and THEN filter. But a join may work. I will probably play with this tomorrow at work but just wanted this up here if anyone knew.