This project is read-only.

using linq set operators on derived classes

Apr 8, 2011 at 10:13 PM

it seems i cannot use .except linq method on a derived class

for example

I have a user class that inherits from a person class.

Dim o = Comp.Business.Objects.UserCollection.RunSelect.Except (does not compile)

while on a non inherited class (like role)   does compile

 Dim o = Comp.Business.Objects.RoleCollection.RunSelect.Except(.....) (does compile)

is this by design and is there a way to overcome a situation like this ?




Apr 13, 2011 at 2:59 PM

For inherited objects sometimes the compiler gets confused. You might need explicitly declare the type. Please see below in C#. I do not know how to write it in VB.



Notice that I am defining the object type for the "Except" method. This works with all LINQ methods like this.
var q = CustomerCollection.RunSelect();
var i = q.FirstOrDefault<Customer>(); 

Apr 14, 2011 at 8:36 PM

well i tried it in both and c# environment.

(vs 2008  .net 3.5)

In c# it does compile as shown in example

but in the same code does not compile.

So it must be one of those c# to incompatibilities.

Don't know if it is resolved in .net framework 4.0 .

Hope it is .



Apr 14, 2011 at 9:50 PM

The syntax is different I am sure. There is some way to explicitly specify the object type I know in VB.