Question : How can i do insert more data with insert query with more select statment linqToSQL?

How can i use insert into myTABLE (. . . .. . ) select * from(.......). i try to write some linq query but i can not. Look please linq query.

SQL:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
 INSERT INTO ActualAmountsByLocation (ItemBarcode, Location, LocationName, Amount, isCustomerItem, LastUpdate)
                        SELECT * FROM (
                            SELECT DISTINCT m.ItemBarcode,m.ToLocationType+m.ToNo AS Location,l.shortdesc AS LocationName, dbo.spGetActualAmountByLocation(m.ItemBarcode,m.ToLocationType+m.ToNo) AS Amount, 0 AS isCustomerItem,
 GETDATE() AS LastUpdate FROM dbo.StockMovement m, RefLocations l WHERE m.ToLocationType='L' AND m.ToLocationType+m.ToNo=l.code AND m.ItemBarcode=@Barcode AND m.TransactionType=1
                        ) a ORDER BY ItemBarcode,Location
                        UPDATE ActualAmountsByLocation SET isCustomerItem=1 WHERE ItemBarcode IN (SELECT barcode FROM StockMaterials WHERE barcode=@Barcode AND ownership=1)
                        UPDATE ActualAmountsByLocation SET isCustomerItem=1 WHERE ItemBarcode IN (SELECT barcode FROM StockTools WHERE barcode=@Barcode AND ownership=1)
                        UPDATE ActualAmountsByLocation SET isCustomerItem=1 WHERE ItemBarcode IN (SELECT barcode FROM StockComponents WHERE barcode=@Barcode AND ownership=1)
                        SET @ReturnMsg = RTRIM(@ReturnMsg) + 'E25: Transaction completed successfully ' + CHAR(13) + CHAR(10)

Linq:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
        if (ToLocationType == 'L')
                       {
                           var stokRefLocation = (from m in stockMovementCtx.StockMovements
                                                  from l in stockMovementCtx.RefLocations
                                                  where m.ToLocationType == 'L' && m.ToLocationType + m.ToNo == l.code &&
                                                  m.ItemBarcode == Barcode && m.TransactionType == 1
                                                  orderby m.ItemBarcode, l.shortdesc
                                                  select new
                                                  {
                                                      myItemBarcode= m.ItemBarcode,
                                                      myLocation = m.ToNo + m.ToNo,
                                                      myLocationName = l.shortdesc,
                                                      myAmount = stockMovementCtx.spGetActualAmountByLocation(m.ItemBarcode, m.ToLocationType + m.ToNo),
                                                      myIsCustomerItem = 0,
                                                      myLastUpdate = DateTime.Now
                                                  }).Distinct();




                           var stokMovement2 = new ActualAmountsByLocation()
                           { 
                                 ItemBarcode = stokRefLocation. //... .. . .  . -< how can i do that? i want to see stokRefLocation.myItemBarcode
                           }
                       }
                   }

Answer : How can i do insert more data with insert query with more select statment linqToSQL?

Random Solutions  
 
programming4us programming4us