首页 新闻 搜索 专区 学院

ling 中Contains为什么报异常

0
悬赏园豆:10 [已解决问题] 解决于 2012-10-20 06:03

这是代码:

    List<Guid>list = new List<Guid>();

 var info = from businessUnit in context.CreateQuery<BusinessUnit>()

                               join user1 in context.CreateQuery<crm_User>()

                               on businessUnit.BusinessUnitId equals user1.crm_businessunit_id.Id

                               where list.Contains(businessUnit.BusinessUnitId.Value)

                               select new
                               {
                                  BusinessUnitId = businessUnit.BusinessUnitId,

                                   userName = user1.crm_name,

                                   buName = businessUnit.Name
                               };
季小鱼的主页 季小鱼 | 菜鸟二级 | 园豆:249
提问于:2012-10-11 21:14
< >
分享
最佳答案
0

Guid转为string试试。我想是不是Guid不能这样比较。

收获园豆:10
forhells | 小虾三级 |园豆:519 | 2012-10-13 11:01
其他回答(2)
0

报什么错呢?你的businessUnit.BusinessUnitId.Value不是Guid?

田林九村 | 园豆:2367 (老鸟四级) | 2012-10-11 21:17

是的

支持(0) 反对(0) 季小鱼 | 园豆:249 (菜鸟二级) | 2012-10-11 21:26

是的,这是异场信息

 System.NotSupportedException: Invalid 'where' condition. An entity member is invoking an invalid property or method. at Microsoft.Xrm.Sdk.Linq.QueryProvider.ThrowException(Exception exception) at Microsoft.Xrm.Sdk.Linq.QueryProvider.FindValidEntityExpression(Expression exp, String operation) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereMethodCall(MethodCallExpression mce, FilterExpressionWrapper parentFilter, Func`2 getFilter, BinaryExpression parent, Boolean negate) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereBoolean(String parameterName, Expression exp, FilterExpressionWrapper parentFilter, Func`2 getFilter, List`1 linkLookups, BinaryExpression parent, Boolean negate) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(QueryExpression qe, String parameterName, Expression exp, List`1 linkLookups) at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetQueryExpression(Expression expression, Boolean& throwIfSequenceIsEmpty, Boolean& throwIfSequenceNotSingle, Projection& projection, NavigationSource& source, List`1& linkLookups) at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression) at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetEnumerator[TElement](Expression expression) at Microsoft.Xrm.Sdk.Linq.Query`1.GetEnumerator() at OFECommonDAC.MachinePartsMortgageUserDAC.GetInfomation(List`1 list) in C:\Users\i-myrone\Documents\Visual Studio 2010\Projects\NEW_OFE\OFECommonDAC\MachinePartsMortgageUserDAC.cs:line 631 at OFECommonBC.MachinePartsMortgageUserBC.GetMachinePartsMortgageUser(String guid) in C:\Users\i-myrone\Documents\Visual Studio 2010\Projects\NEW_OFE\OFECommonBC\MachinePartsMortgageUserBC.cs:line 88 at OFEItemManagement.OFEOtherTransaction.web.MachinePartsMortgageUser.btnSearch_Click(Object sender, EventArgs e) in C:\Users\i-myrone\Documents\Visual Studio 2010\Projects\NEW_OFE\OFEItemManagement\OFEOtherTransaction\web\MachinePartsMortgageUser.aspx.cs:line 299

支持(0) 反对(0) 季小鱼 | 园豆:249 (菜鸟二级) | 2012-10-11 21:30
0

这异常 英文的没看懂,

businessUnit.BusinessUnitId 是不是还有null值, list<Guid>的contains允许null 吗?

Qlin | 园豆:2403 (老鸟四级) | 2012-10-12 09:32

不是,因该是上个页面传过来的!

支持(0) 反对(0) 季小鱼 | 园豆:249 (菜鸟二级) | 2012-10-12 16:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册