我得到一個例外,當我執行此代碼:LINQ:轉換GUID來串
var result = from menu in menuBus.GetMenus()
orderby menu.InternalName
select new
{
Value = menu.ID.ToString(),
Text = menu.InternalName
};
var result = allMenus.ToList();
錯誤消息說:LINQ到實體無法識別方法「System.String的ToString()」方法,並且此方法不能被轉換爲存儲的表達式。
所以,我猜是Value = menu.ID.ToString()出了問題。 ID屬性被定義爲GUID(MS SQL中的UniqueIdentifier)。
有沒有人有解決方案?
非常感謝!
謝謝George,您的解決方案對我來說非常棒! – Ingmar