I have an entity with three columns, a, b, and c. If I project the ObjectSet to objects of an anonymous class:
var ret = e.foos.Select(x => new {
a = x.a,
b = x.b
}).ToList();
Then the actual SQL only includes the columns necessary to populate each object:
SELECT
[Extent1].[a] AS [a],
[Extent1].[b] AS [b]
FROM [dbo].[foo] AS [Extent1]
If I include the EntityObject as a property of the anonymous class, then all columns in the entity are included in the SQL, even though only "a" and "b" are called out explicitly:
var ret = e.foos.Select(x => new {
a = x.a,
b = x.b,
o = x
}).ToList();
SELECT
[Extent1].[a] AS [a],
[Extent1].[b] AS [b],
[Extent1].[c] AS [c]
FROM [dbo].[foo] AS [Extent1]
Is there a way I can exclude column "c" from being fetched from the database while still having a reference to the EntityObject in my anonymous object?