I've been playing around with LINQ to SQL and I just have a couple of simple questions:
- When do I need Select on the end of my query?
- When can I omit the Select?
Here are my example queries:
Dim pageRoute = From r In db.PageRoutes Where r.PageId = pageId Order By r.Id Descending
Dim pageRoute = From r In db.PageRoutes Where r.PageId = pageId Order By r.Id Descending
Dim dp = From r In db.DownloadPageOnlineOnlies Where r.PageId = pageId Order By r.Weight Descending, r.Id Ascending
Dim download = (From r In db.Downloads Where r.Id = id).First
- Are any of them technically wrong?
- Could they be improved with a Select or something else?
In a nutshell, I don't understand when I would need either:
Select r
Select r.AColumnINeed, r.BColumnINeed (does this improve performance?)
Thanks.
P.S. I like to write my LINQ queries on one line unless they are really big.