本文整理汇总了C#中Common.List.ToOrExpression方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToOrExpression方法的具体用法?C# List.ToOrExpression怎么用?C# List.ToOrExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.ToOrExpression方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItems
public static IEnumerable<Item> GetItems(GetItemsRequest request)
{
// If we don't have what we need to make this call, stop here.
if (request.Configuration == null)
throw new InvalidRequestException("ExigoService.GetItems() requires an OrderConfiguration.");
if (request.Configuration.CategoryID == 0 && request.CategoryID == null && request.ItemCodes.Length == 0)
throw new InvalidRequestException("ExigoService.GetItems() requires either a CategoryID or a collection of item codes."); ;
// Set some defaults
if (request.CategoryID == null && request.ItemCodes.Length == 0)
{
request.CategoryID = request.Configuration.CategoryID;
}
// Create the contexts we will use
var context = Exigo.OData();
// Determine how many categories we need to pull based on the levels. Currently designed to go one level deep.
var categoryIDs = new List<int>();
if (request.CategoryID != null)
{
categoryIDs.Add((int)request.CategoryID);
if (request.IncludeChildCategories)
{
// Get the child categories
var ids = context.WebCategories
.Where(c => c.WebID == 1)
.Where(c => c.ParentID == (int)request.CategoryID)
.Select(c => new
{
c.WebCategoryID
}).ToList();
categoryIDs.AddRange(ids.Select(c => c.WebCategoryID));
}
}
// If we requested a specific category, get the item codes in the category
if (categoryIDs.Count > 0)
{
var categoryItemCodes = context.WebCategoryItems
.Where(c => c.WebID == 1)
.Where(categoryIDs.ToOrExpression<WebCategoryItem, int>("WebCategoryID"))
.Select(c => new
{
c.Item.ItemCode
}).ToList();
var existingItemCodes = request.ItemCodes.ToList();
existingItemCodes.AddRange(categoryItemCodes.Select(c => c.ItemCode).Distinct().ToList());
request.ItemCodes = existingItemCodes.ToArray();
}
// If we don't have any items, stop here.
if (request.ItemCodes.Length == 0) yield break;
// Get the data
var query = context.ItemWarehousePrices.Expand("Item")
.Where(c => c.WarehouseID == request.Configuration.WarehouseID)
.Where(c => c.PriceTypeID == request.Configuration.PriceTypeID)
.Where(c => c.CurrencyCode == request.Configuration.CurrencyCode);
if (request.ItemCodes != null && request.ItemCodes.Count() > 0)
{
query = query.Where(request.ItemCodes.ToList().ToOrExpression<ItemWarehousePrice, string>("Item.ItemCode"));
}
var odataItems = query.ToList();
var items = odataItems.Select(c => (ExigoService.Item)c).ToList();
// Populate the group members and dynamic kits
PopulateGroupMembers(items, request.Configuration);
PopulateDynamicKitMembers(items);
// Return the data
foreach (var item in items)
{
yield return item;
}
}