This LINQ to SQL query
From g In Db.Context.Current.Groups
Select g.GroupID
generates this SQL:
SELECT [t0].[GroupID]
FROM [dbo].[Groups] AS [t0]
But this query
From g In Db.Context.Current.Groups
Select g.GroupID, g.MemberCount
generates this SQL:
SELECT
[t0].[GroupID], [t0].[Title], [t0].[Description], ...
-- 24 more fields - omitted for brevity
FROM [dbo].[Groups] AS [t0]
g.MemberCount
is a property of the Group
class that returns an integer.
Public ReadOnly Property MemberCount() As Integer
Get
Return (
From cgx In KN.Db.Context.Current.ContactsGroupsXtabs
Where cgx.GroupID = Me.GroupID
Select cgx.ContactID
).Count()
End Get
End Property
I very much want to select only the fields I need. How can I persuade LINQ to SQL not to select all columns?