I have 2 tables: Oceny_przedmioty and Studenci. Studenci and Oceny_przedmioty are in connection one - many (one student can have more than 1 grade). I need to make from this SQL :
SELECT Oprz_Ocena
FROM Oceny_przedmioty
UNION SELECT ST_Nr_indeksu
FROM Studenci
WHERE ST_Nr_indeksu = '11000'
linq expression what Visual Studio will understand. I work with entity framework. I tried something like this
var currentGrade= (from Oceny_przedmioty in dbContext.Oceny_przedmioty
select Oceny_przedmioty.ID_Studenta).Union
(from Studenci in dbContext.Studenci
select Studenci.ID_Studenta);
but it doesn't even recognizes Union (does not contain a definition for Union). Thanks for any help in advance!
using System.Linq;in order to use the .Union() functionOceny_przedmioty.ID_Studentatype isint?(nullable int) whileStudenci.ID_Studentajustint. Parts of theUnionhas to have one and the same element type. Why don't you select the fields corresponding to your SQL query (which seem to bestrings).select Oceny_przedmioty.ID_Studentawithselect Oceny_przedmioty.ID_Studenta.Value