vb.net lambda expression problem
I am having an strange problem in visual studio 2010, visual basic, and using linq. My lamda expressions are not showing up in intellesence. The project I am working on was created in visual studio 2008 and I have converted it to a visual studio 2010 project.
Here is the expression I am trying to run:
ClockItemsColl.Filter = ClockItemsColl.AsQueryable().OrderBy(d >= d.Second)
However the error I am getting is:
'd' is not accessible in this context because it is 'Friend'.
I have also tried
ClockItemsColl.Filter = ClockItemsColl.AsQueryable().OrderBy(Function(d As ClockItems) d >= d.Second)
But is still generates an error and I can't make heads or tails of it.
Overload resolution failed because no accessible 'OrderBy' can be called with these arguments: Extension method 'Public Function OrderBy(Of TKey)(keySelector As System.Func(Of BusinessObjects.ClockItems, TKey)) As System.Linq.IOrderedEnumerable(Of BusinessObjects.ClockItems)' defined in 'System.Linq.Enumerable': Operator '>=' is no开发者_Python百科t defined for types 'BusinessObjects.ClockItems' and 'Integer?'. Extension method 'Public Function OrderBy(Of TKey)(keySelector As System.Func(Of BusinessObjects.ClockItems, TKey)) As System.Linq.IOrderedEnumerable(Of BusinessObjects.ClockItems)' defined in 'System.Linq.Enumerable': Data type(s) of the type parameter(s) cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error. Extension method 'Public Function OrderBy(Of TKey)(keySelector As System.Linq.Expressions.Expression(Of System.Func(Of BusinessObjects.ClockItems, TKey))) As System.Linq.IOrderedQueryable(Of BusinessObjects.ClockItems)' defined in 'System.Linq.Queryable': Operator '>=' is not defined for types 'BusinessObjects.ClockItems' and 'Integer?'. Extension method 'Public Function OrderBy(Of TKey)(keySelector As System.Linq.Expressions.Expression(Of System.Func(Of BusinessObjects.ClockItems, TKey))) As System.Linq.IOrderedQueryable(Of BusinessObjects.ClockItems)' defined in 'System.Linq.Queryable': Data type(s) of the type parameter(s) cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
I am using entityspaces to interface with my datalayer, and this is the first time I am using Linq, so I am going through a bit of growing pains.
Thanks for your time.
I believe what you want is closer to this:
ClockItemsColl.Filter = ClockItemsColl.AsQueryable().OrderBy(Function(d) d.Second)
This site is a great 'go to' for learning VB linq syntax.
Let me know if anything else comes up.
精彩评论