How cani use below codes string id = ( from in …..) how?
using (StockProcedureDataContext stock = new StockProcedureDataContext())
{
id = (from m in stock.StockTools
from ss in stock.RefStockStatus
where (m.statusid == 3 || m.statusid == 5) &&
ss.id == m.statusid && m.id == ItemID
select m.id);
How can i do above wthout using below?
id = (from m in stock.StockTools
from ss in stock.RefStockStatus
where (m.statusid == 3 || m.statusid == 5) &&
ss.id == m.statusid && m.id == ItemID
select m).ToList()[0].id;
if you want to retrieve a single result user FirstOrDefault() or First().
If you use
First()and the result is null.It will throws exception but not inFirstOrDefault().