0
我有一個Lambda表達式,它根據傳入的ID過濾客戶列表。這很好,但是我想從CreationDate字段中刪除時間戳,當我返回記錄。無論如何要在Lambda表達式中做到這一點?更新/修剪Lambda中的值表達式
所以這是我的Lambda表達式返回我的客戶記錄:
customers = customers.Where(c => c.Business_Type == businessType);
不過,我想這樣做如下:
customers = customers.Where(c => c.Business_Type == businessType, c.CreationDate=c.CreationDate.Value.ToShortDateString());
要回答你的問題,是的,你可以。在以下方法中轉換表達式:customers = customers.Where(c => {bool r = c.Business_Type == businessType; c.CreationDate = c.CreationDate.Value.ToShortDateString(); return r});不是建議... – Polity 2012-02-17 10:02:31