I have this simple SQL:
SELECT name, value
FROM table1 t1, table2 t2
WHERE t1.id = t2.id
AND t1.id = 123
How do I convert it to LINQ in C#, so that the results are in Dictionary?
I have this simple SQL:
SELECT name, value
FROM table1 t1, table2 t2
WHERE t1.id = t2.id
AND t1.id = 123
How do I convert it to LINQ in C#, so that the results are in Dictionary?
I'm guessing you are using Entity Framework? Could you use RelationShips instead?
Or like this:
var query = from t1 in context.Table1
from t2 in context.Table2
where t1.Id == t2.Id
select new { t1.name, t2.value};
var result = query.ToList();
var dir = result.ToDictionary(x => x.name, x => x.value);
https://docs.microsoft.com/en-us/ef/core/querying/complex-query-operators