首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

对于方法 String.Contains,只支持可在客户端上求值的参数。 -这是咋回事?

2012-01-08 
对于方法 String.Contains,只支持可在客户端上求值的参数。 --这是怎么回事?.代码如下:C# codevar select

对于方法 String.Contains,只支持可在客户端上求值的参数。 --这是怎么回事?.
代码如下:

C# code
var select = from ar in adc.Articles                             from au in adc.Authors                             where ar.ShowTime > timeset && ar.AuthorType == typeid && ar.Author.Contains(au.Name) == true && ar.Title.Contains(au.Name) == true                             orderby ar.ShowTime descending                             select new                             {                                 arid = ar.Id,                                 ar.Code,                                 ar.Title,                                 ar.ShowTime,                                 auid = au.Id,                                 au.Name,                                 au.PinYin,                                 au.GoUrl                             };                foreach (var item in select)                {                    AuthorArticle aa = new AuthorArticle();                    aa.ArticleId = item.arid;                    aa.ArticleCode = item.Code;                    aa.ArticleTitle = item.Title;                    aa.ArticleShowTime = item.ShowTime;                    aa.AuthorId = item.auid;                    aa.AuthorName = item.Name;                    aa.AuthorNamePY = item.PinYin;                    aa.AuthorGoUrl = item.GoUrl;                    aalist.Add(aa);                }


[解决办法]
Linq to SQL限制了一些方法。你可以考虑使用join等它支持可以直接转换为T-SQL语句的方法。

如果一定要使用它不支持的计算方法,你可以先使用Linq to SQL查询出可以查询的那些结果,然后在结果的 ToList() 的基础上再用一条 Linq to object查询来继续你的计算。

不过应该首先改为它支持的查询方法为好。

热点排行