So, if you’ve been going through the System.Data.Services.Internal namespace, you might have noticed that the types are rather visible. What’s up with that?
Well, the types are used to ask LINQ provider to do $expand projections as necessary. Projecting is rather interesting, because the providers will need to look at these types and instantiate them at some point or another. We wanted LINQ provider writer to be able to write code that didn’t require requesting any privilege elevations to get at these types and instantiate them, call methods on them and so on and so forth.
Typically the projection can be done using LINQ to Objects and by making the types visible, ‘it just works’ from any privilege level – a LINQ implementation could generate IL referencing these types, use reflection over visible types, or whatever strategy they choose to implement.
And now you know.