我有一個包含三列a,b和c的實體。如果一期項目的對象集到一個匿名的類的對象:在不包括所有列的情況下在LINQ中包含EntityObject到實體投影
var ret = e.foos.Select(x => new {
a = x.a,
b = x.b
}).ToList();
然後實際的SQL只包含必要來填充每個對象列:
SELECT
[Extent1].[a] AS [a],
[Extent1].[b] AS [b]
FROM [dbo].[foo] AS [Extent1]
如果我包括EntityObject作爲的屬性匿名類,然後在實體中的所有列都包含在SQL,即使只有「A」和「b」被召喚出來明確:
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]
有沒有一種方法,我可以排除列從數據庫中獲取「c」,同時仍然引用我的匿名對象中的EntityObject?