2
Answers

linq and looping

Nymhar Quines

Nymhar Quines

11y
1.1k
1
Sample data from table: Table Name - SUPPLIERS and Entity Name - dbData


RECORD_NO     ID_NO      FIRST_BRANCH     SECOND_BRANCH   POSITION
----------------------------------------------------------------
   1      05100242     05100243         05100244         L
   2       05200443     05100245         05100247         L
   3       05100244     05100248                          R
   4       05100245     05100249                           L
   5       05100247     05100250                           R
   6       05100248                                        L
   7       05100249                                        L
   8       05100250                                        L




if you get all the branch of 05100242, use the query 
int suppliers = dbData.SUPPLIERS.where(x=>x.RECORD_NO !=1).Count();


THE QUESTION IS HOW ARE YOU GOING TO GET THE SUPPLIERS(COUNT) OF 05100243 & 05100244 using query and loop OR ANY METHOD USE TO GET THE RESULTS?


TO GET THE RESULT OF 05100242 I used
var data = dbData.SUPPLIERS.where(x=>x.ID_NO == 05100243);
string left = data.FIRST_BRANCH;
var leftbranch = dbData.where(x=>x.ID_NO == left);
string right = data.SECOND_BRANCH;
var leftbranch = dbData.where(x=>x.ID_NO == right);






YOU CAN USE THAT METHOD BUT MANUALLY SPEAKING,YOU DID'NT KNOW HOW TO STOP AND HOW MANY ROWS BECAUSE IT IS INCREASING.




ANYONE WHO KNOWS THE SOLUTION FOR THIS? using a class that will count the left and right side?
Answers (2)