I'm working with vb.net and entity framework.
In my form , I have 2 comboboxes : Article and price. ( For both comboboxes , .Selectedvalue is an integer )
If I use this expression :
Dim gj As IEnumerable(Of Myobject)
gj = (From t In context.myobjects Where t.art = Article.SelectedValue And t.prc = price.SelectedValue
Select t).ToList
an error is produced :
An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dllAdditional information: LINQ to Entities does not recognize the method 'System.Object CompareObjectEqual(System.Object, System.Object, Boolean)' method, and this method cannot be translated into a store expression.
If I use this code :
Dim gj As IEnumerable(Of Myobject)
gj = (From t In context.myobjects Where t.art = Article.SelectedValue.ToString And t.prc = price.SelectedValue.ToString
Select t).ToList
everything is OK.
The problem is that i'm not sure that using the ToString method could produce a correct result everytime because t.art and t.prc are integers.
Can you give me an explanation , and what should i do ?
Thank you !