0

I'm trying to write a LINQ for the below query,

Select DIS.iDataItemID, DIS.iDataItemCurrentStatusID, DI.iDataTypeID, 
DI.iEmployeeID, DI.iEmployerID, DI.iLinkID, DI.iSystemID, DI.sData, 
DI.sEmployerCode, DI.sRecieptID, COunt(*)
from DataItem DI
INNER JOIN DataItemStatus DIS ON DIS.iDataItemID = 
DI.iDataItemID 
INNER JOIN RefDataItemStatus ON DIS.iDataItemCurrentStatusID 
= RefDataItemStatus.iDataItemStatusID
AND DIS.iDataItemCurrentStatusID = 1 AND DI.iDataTypeID = 8 
GROUP BY DIS.iDataItemID, DIS.iDataItemCurrentStatusID, DI.iDataTypeID, 
DI.iEmployeeID, DI.iEmployerID, DI.iLinkID, DI.iSystemID, DI.sData, 
DI.sEmployerCode, DI.sRecieptID

I have written the LINQ as below, Need to know how to use Group by on this,

from dataItem in msaDBContext.DataItem
                                 join dataItemStatus in msaDBContext.DataItemStatus on dataItem.iDataItemID equals dataItemStatus.iDataItemID
                                 join refDataItemStatus in msaDBContext.RefDataItemStatus on dataItemStatus.iDataItemCurrentStatusID equals refDataItemStatus.iDataItemStatusID
                                 where dataItemStatus.iDataItemCurrentStatusID == _processingStatus.iDataItemStatusID && dataItem.iDataTypeID == _dataType.iDataTypeID
                                 select new
                                 {
                                     iDataItemID = dataItem.iDataItemID,
                                     iDataItemCurrentStatusID = dataItemStatus.iDataItemCurrentStatusID,
                                     iDataTypeID = dataItem.iDataTypeID,
                                     iLinkID = dataItem.iLinkID,
                                     biRowVersion = dataItem.biRowVersion,
                                     sData = dataItem.sData,
                                     iEmployeeID = dataItem.iEmployeeID,
                                     iEmployerID = dataItem.iEmployerID,
                                     sEmployerCode = dataItem.sEmployerCode,
                                     iSystemID = dataItem.iSystemID,
                                     sReceiptID = dataItem.sRecieptID
                                 };
Aryan M
  • 571
  • 3
  • 12
  • 33
  • What exactly do you want to group up? – John Wu Jul 24 '18 at 21:43
  • 2
    Perhaps my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786) might help you? – NetMage Jul 24 '18 at 21:45

0 Answers0