For example, we can
have the following query, which produces the sequence for categories:
// Sequence
var categoriesDetails = categories.Select(n => new
{
CategoryID = n.Field
("CategoryID"),
Category = n.Field("CategoryName"),
Description = n.Field("Description")
});
foreach (var categoryDetails in categoriesDetails)
{
Console.WriteLine("CategoryID:" + categoryDetails.CategoryID + "
Category:" + categoryDetails.Category + " Description:" +
categoryDetails.Description);
}
Chapter 5
[ 147 ]
We can also apply the sequence on joins between tables. For example, following is an
equivalent query for the join query we saw earlier.
// Sequence on Joins
var rowItmCategories = categories.Where(cat => cat.
Field("CategoryID") == 1)
.SelectMany(cat => cat.GetChildRows("CategoryItems")
.Select(itms =>new
{
itemID = itms.Field("IItemID"),
categoryType = itms.Field("CategoryType"),
itmName = itms.Field("Name")
}));
foreach (var rowItemcats in rowItmCategories)
{
Console.
Pages:
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231