LINQ的Guid的toString() [英] LINQ Guid toString()
本文介绍了LINQ的Guid的toString()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这似乎像它应该工作,
from something in collectionofsomestuff
select new SelectListItem(){Text = something.Name, Value = something.SomeGuid.ToString(), Selected = false};
当我试图做到这一点不起作用给我误差
When I try to do this it doesn't work give me error
LINQ到实体无法识别方法'System.String的ToString()方法,而这种方法不能被翻译成店的表情。
LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
有没有解决办法?
推荐答案
并非所有的CLR方法可以使用LINQ到实体使用。 toString()方法似乎是其中之一。
Not all CLR methods can be used with Linq-to-Entities. ToString() seems to be one of them.
看看的 CLR法规范功能映射。
也许尝试的GUID明确设置为一个字符串变量,外面的LINQ的。
Maybe try setting the GUID to a string variable explicitly, outside of Linq.
string myGuid = SomeGuid.ToString();
from something in collectionofsomestuff
select new SelectListItem(){Text = Name, Value = myGuid, Selected = false};
这篇关于LINQ的Guid的toString()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文