首页 新闻 会员 周边

Linq to sql遇到p.CategoryIDs.Split(',').Contains(id)

0
悬赏园豆:50 [已解决问题] 解决于 2009-05-24 21:04

由于一个产品可能属于多种分类。所以Products表中的CategoryIDs格式是用"1,2,3"这种形式。
搜索指定类别的产品时,使用Linq to sql

IQuarable<Product> result =

                                         from p in dataContext.Products
                                         where p.CategoryIDs.Split(',').Contains(categoryID.ToString());

会抛异常。base {System.SystemException} = {"Comparison operators not supported for type 'System.String[]'"}不知道是何原因。

a-peng的主页 a-peng | 初学一级 | 园豆:28
提问于:2009-05-24 19:07
< >
分享
最佳答案
0

把CategoryIDs改成"[1][2][3]"这样的格式就可以不用Split乐

水言木 | 小虾三级 |园豆:586 | 2009-05-24 20:42
其他回答(1)
0

并不是每个方法都能翻译成sql语法的,似乎Split方法就不能翻译

Gray Zhang | 园豆:17610 (专家六级) | 2009-05-24 20:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册