首页 > 其他 > 详细

linq query, using int.parse to convert varchar to int while orderby

时间:2014-02-16 21:33:59      阅读:374      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
var t = from x in context.NewsLetterItem.ToList() //add .ToList at this place
                            where x.APPId == appid &&
                                allowedAddress.Contains(x.mailFrom)
                            orderby int.Parse(x.mailId) descending
                            select x;
bubuko.com,布布扣

 

else, if you use the following query,  an erro with following message would be thrown:

LINQ to Entities does not recognize the method ‘Int32 Parse(System.String)‘ method, and this method cannot be translated into a store expression.

bubuko.com,布布扣
var t = from x in context.NewsLetterItem
                            where x.APPId == appid &&
                                allowedAddress.Contains(x.mailFrom)
                            orderby int.Parse(x.mailId) descending
                            select x;
bubuko.com,布布扣

linq query, using int.parse to convert varchar to int while orderby

原文:http://www.cnblogs.com/zyip/p/3551156.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!