I have 5 tables in L2S dbml classes: Global -> Categories -> ItemType -> Item -> ItemData. In the example below, I only reached item item.
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Global>(p => p.Category);
options.AssociateWith<Global>(p => p.Category.OrderBy(o => o.SortOrder));
options.LoadWith<Category>(p => p.ItemTypes);
options.AssociateWith<Category>(p => p.ItemTypes.OrderBy(o => o.SortOrder));
cdc.LoadOptions = options;
TraceTextWriter traceWriter = new TraceTextWriter();
cdc.Log = traceWriter;
var query =
from g in cdc.Global
where g.active == true && g.globalid == 41
select g;
var globalList = query.ToList();
foreach (var g in globalList)
{
List<Category> categoryList = g.category.ToList<Category>();
var categories = (from comp in categoryList
where comp.Type == i
select comp).ToList<Category>();
foreach (var c in categories)
{
List<ItemType> typeList = c.ItemTypes.ToList<ItemType>();
var itemTypes = (from cat in TypeList
where cat.itemLevel == 2
select cat).ToList<ItemType>();
foreach (var t in itemTypes)
{
}
}
}
"List typeList = c.ItemTypes.ToList ();"
This line is executed multiple times in foreach, and the query is executed to get the results, and I understand why to some extent, but I thought that it would reliably load Loadwith as an option, as in the case of fetching with just one query.
, , L2S "" , , " ", . , . , itemtype . - ( * ItemTypes Where CategoryID ( categoryID , GlobalID (#, #, #))
, , , , , , , , , .