I would use the System.Linq.Dynamic.
I added the specified
Dynamic.vb file, that starts like this :
Option Strict On Option Explicit On Imports System.Collections.Generic Imports System.Text Imports System.Linq Imports System.Linq.Expressions Imports System.Reflection Imports System.Reflection.Emit Imports System.Threading Imports System.Runtime.CompilerServices Namespace System.Linq.Dynamic Public Module DynamicQueryable
to my (VB.NET)solution.
Now Visual Studio does not recognize anymore in the project files the
System.XXX references, proposing me to change them to
Was is Das, and how to manage it?
It looks as though some namespace hiding is taking place. In VB.NET projects a root namespace exists that is set to your project's name by default. You can check this from Project -> Properties -> Application -> Root namespace.
When a class explicitly specifies a namespace, the root namespace is prefixed to it. For example, let's say your root namespace is
RootNs. Since the
DynamicLinq.vb file specifies a namespace of
System.Linq.Dynamic this is really
RootNs.System.Linq.Dynamic. This hides the regular .NET
System namespace, which is why Visual Studio prompts you to prefix all your namespaces with
It's worth noting that in C# this concept is different, so I wouldn't expect this issue to come up when someone uses the C# version of
To fix this you have a few options (pick one):
Remove the namespace declaration from
DynamicLinq.vb and remove any full qualifications from objects within that file that use
System.Linq.Dynamic. In other words,
Signature. To use it elsewhere, add
Remove the root namespace from Project/Properties/Application by making it blank. By doing so your project will be more like C# and you ought to explicitly specify namespaces in all your classes. To use it elsewhere, add
Keep the root namespace and just change the namespace of
DynamicLinq.vb. For example, change it to
NewNs.Linq.Dynamic and remove full qualifications from
Signature as before. To use it elsewhere, add
Imports RootNs.NewNs.Linq.Dynamic (notice the