'Linq query showing more data than the SQL alternative

I have an linq query like this :

var query = from Romm in RoMM
                        
                        join rfrsa in RoMmfrsa  on Romm.RoMmid equals rfrsa.RoMmid
                        join frsa in Frsa on rfrsa.Frsaid equals frsa.Fraid
                        join fra in Fra on frsa.Fraid equals fra.Fraid
                        where Romm.ActTypeId == 2 && Romm.SegmentId == 4
                        select new
                        {
                            Romm.ActTypeId,
                            Romm.RoMmid,
                            frsa.Fraid,
                            frsa.Frsaid,
                            Romm.ImpactId
                        };

And I have SQL code as below :

SELECT romm.ROMMID 

     , frsa.FRAID 

     , frsa.FRSAID 

     , romm.ImpactID 

  FROM RoMM AS romm 

 INNER 

  JOIN RoMMFRSA AS rfrsa 

    ON romm.RoMMID = rfrsa.RoMMID 

 INNER 

  JOIN FRSA AS frsa 

    ON rfrsa.frsaid = frsa.frsaid 

 INNER 

  JOIN FRA AS fra 

    ON frsa.FRAID = fra.FRAID 

 WHERE romm.acttypeid = 2 

   AND romm.segmentid = 4

The SQL only shows one row (which is correct), the linq shows the correct row and then it displays about another 3 rows which is not what we need. I need the linq to show one row which is correct with the SQL. Is this because of maybe many-many relationships ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source