3
我想弄清楚返回類型。它看起來像ToList()返回一個列表,但我不知道什麼類型。這個Linq to SQL返回什麼數據類型?
var id = (from h in db.t_ref_harvest_type
where h.manner_of_take_id == methodOfTakeId &&
parsedSeasons.Contains((int)h.season) && h.active == true
select new { h.id, h.harvest_type }).ToList();
好的,然後我的方法應該返回什麼類型?它只是返回var id。或者更好的說,我該如何返回一個匿名類型列表? – KeelRisk 2012-03-14 04:57:43
@KeelRisk - 你不能從方法中返回匿名類型列表...如果你只是想返回id而不是修改查詢,請選擇「列表 lstid =(..... Select h.id).ToList () ;」和回報lstid..will對你 –
2012-03-14 05:00:39
好吧,我想我需要循環的結果,並拿出id。謝謝 – KeelRisk 2012-03-14 05:02:09