这是代码:
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 };
Guid转为string试试。我想是不是Guid不能这样比较。
报什么错呢?你的businessUnit.BusinessUnitId.Value不是Guid?
是的
是的,这是异场信息
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
这异常 英文的没看懂,
businessUnit.BusinessUnitId 是不是还有null值, list<Guid>的contains允许null 吗?
不是,因该是上个页面传过来的!