if i try to write below codes : error return to me: The query results cannot be enumerated more than once
public void StartTransaction()
{
using (var stockMovementCtx = new StockMovementCtxDataContext())
using (var scope = new TransactionScope())
{
var stockMovementItems = from s in stockMovementCtx.spStockMovementForTransaction(TicketID, ItemTypeNo, ItemID, TransactionType,
FromLocation, ToLocation, Qty, PersonelNo, cuser
)
select s;
ReturnCode = stockMovementItems.First().ReturnCode;
// MessageBox.Show(stockMovementItems.First().ToString());
ReturnMsg = stockMovementItems.First().ReturnMessage;
TransactionType = stockMovementItems.First().TransactionType;
TicketID = stockMovementItems.First().TicketID;
Detail :



Short fix:
then
or
but the latter is kind of an abuse of Linq.
Longer answer is that whatever stockMovementCtx.spStockMovementForTransaction(..) is, it only supports forward reading. Thus when you call First() you advance to the next result and cannot go back.