So I have two tables that have a layout like (but not named):
Table A
-------
AID
Title
ACol1
ACol2 ... (to ACol60)
and
Table B
-------
BID
AID
Title
BCol1
BCol2 ... (to BCol30)
I built a simple class
public class SimpleCollection
{
public Guid ID { get; set; }
public string Title { get; set; }
public IEnumerable<SimpleCollection> Elements { get; set; }
}
What I’m trying to do is two fold:
- Return in a single call all the parent/child rows.
- Select only the columns I need so I’m not pulling the 60/30 extra columns I don’t need.
I tried the following:
var query = from A in dbContext.TableA
from B in A.TableB
select new SimpleCollection()
{
ID = A.AID,
Title = A.Title,
Elements = select new SimpleCollection<string>()
{
ID = B.BID,
Title = B.Title
}
};
But it doesn’t like setting Elements to a select statement.
I believe I was over thinking the problem.