I have this older Linq query that is throwing the error 'Could not be translated'. I'm pretty good with lambda expressions, but not join intos.
For the sake of privacy, I've renamed the tables. These aren't the actual names of the tables!
var data = (from a in db.TableA
join b in db.TableB on a.Id equals c.Id
join c in db.TableC on a.OtherId equals c.Id
into grp
from g in grp.Take(1)
join d in db.D on g.SomethingId equals d.SomethingId
where.....
orderby c.Name
select new {
...
}).toList()
So all of it works until the 'into group from g in grp.Take(1)
I have no idea how to rewrite this so that .Net Core 3.1 can read it.
I can provide the where statements and the properties of the select new if really needed, but I don't think it's really that important.
CodePudding user response:
Rewrite your query in the following way:
var data =
(from a in db.TableA
join b in db.TableB on a.Id equals c.Id
from c in db.TableC.Where(c => a.OtherId == c.Id).Take(1)
join d in db.D on c.SomethingId equals d.SomethingId
where.....
orderby c.Name
select new {
...
}).toList()