开发者

InvalidOperationException for executing LINQ query

'Initialize The Database Connection'

Dim dbTRCoreDatabase As New TRCoreDatabase

'Query For Get The Employee ID'
Dim listEmployeeID As IQueryable(Of Long) = (From EmpMaster In dbTRCoreDatabase.EmployeeMasters Where EmpMaster.Email = Session("gUserName") Select EmpMaster.EmployeeID)

MsgBox(listEmployeeID(0).ToString)

When i execute this query,I have the following Error.

System.InvalidOperationException: An exception occured during the execution of ' Extent<TR_Portal_Homecare.EmployeeMaster>.Where(EmpMaster => Convert(CompareObjectEqual(Convert(EmpMaster.Email), value(ASP.activeplacement_aspx).Session.get_Item("gUserName"), False))).Select(EmpMaster => EmpMaster.EmployeeID)'. See InnerException for more details. ---> System.InvalidCastException: Unable to cast object of type 'Telerik.OpenAccess.Query.MethodCallTransformation' to type 'OpenAccessRuntime.DataObjects.query.Node'. at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) --- End of inner exception stack trace --- at Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single) at Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQuerySingle[TResult,T](Piece`1 piece, Int32& found, Int32 ele开发者_Go百科mAt, Boolean single) at Telerik.OpenAccess.Query.ExpressionExecution.PerformQuerySingle[T,TResult](Piece`1 piece, Expression expression) at Telerik.OpenAccess.Query.Piece`1.System.Linq.IQueryProvider.Execute[TResult](Expression expr) at System.Linq.Queryable.ElementAtOrDefault[TSource](IQueryable`1 source, Int32 index) at TR_Portal_Homecare.ActivePlacement.Page_Load(Object sender, EventArgs e) in E:\Palanikumar\Project\Today\TRCorePortal\TR_Portal_Homecare\ActivePlacement.aspx.vb:line 12


I think, the error is in your where clause. Check if types of EmpMaster.Email and Session("gUserName") are same. I believe they are not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜