问题描述
我需要一个查询来从CommerceQuery获取LineItems和相关的Disocunts。
I have a requirement for a query to get the LineItems and associated Disocunts from the CommerceQuery for the basket.
任何一个,请告诉我如何创建查询。
Can any one ,please let me know how the query could be created.
我有一个这样的查询来选择baskte
I have a query like this for selecting the baskte
var result = new CommerceModelSearch< CommerceEntities.Basket>();
result.Model.Name = _basketName;
result.Model.UserId = userId.ToString(" B");
result.Model.BasketType =(int)basketType;
//创建定位条件
var targetingContext = new CommerceEntities.TargetingContext();
targetingContext.ChannelName = channel;
result.Model.TargetingContext = new CommerceRelationship();
result.Model.TargetingContext.Target = targetingContext.ToCommerceEntity();
&NBSP; // var targetContext = new CommerceEntities.TargetingContext();
//targetContext.ChannelName = channel;
//result.Model.TargetingContext = new CommerceRelationship();
//result.Model.TargetingContext.Target = targetContext.ToCommerceEntity();
$
&NBSP;&NBSP; basketQuery.SearchCriteria = result;
//添加订单项查询
var lineItemQuery = new CommerceQueryRelatedItem< CommerceEntities.LineItem>(CommerceEntities.Basket.RelationshipName.LineItems);
var itemDiscountsQuery = new CommerceQueryRelatedItem< CommerceEntities.Discount>(CommerceEntities.LineItem.RelationshipName.ItemLevelDiscounts);
var basketDiscountsQuery = new CommerceQueryRelatedItem< CommerceEntities.Discount>(CommerceEntities.LineItem.RelationshipName.BasketLevelDiscounts);
lineItemQuery.RelatedOperations.Add(basketDiscountsQuery);
lineItemQuery.RelatedOperations.Add(itemDiscountsQuery);
$
basketQuery.RelatedOperations.Add(lineItemQuery);
$
var promoCodesQuery = new CommerceQueryRelatedItem< CommerceEntities.RequestedPromoCode>(CommerceEntities.Basket.RelationshipName.RequestedPromoCodes);
basketQuery.RelatedOperations.Add(promoCodesQuery);
var result = new CommerceModelSearch<CommerceEntities.Basket>();
result.Model.Name = _basketName;
result.Model.UserId = userId.ToString("B");
result.Model.BasketType = (int)basketType;
// create the targeting context
var targetingContext = new CommerceEntities.TargetingContext();
targetingContext.ChannelName = channel;
result.Model.TargetingContext = new CommerceRelationship();
result.Model.TargetingContext.Target = targetingContext.ToCommerceEntity();
//var targetContext = new CommerceEntities.TargetingContext();
//targetContext.ChannelName = channel;
//result.Model.TargetingContext = new CommerceRelationship();
//result.Model.TargetingContext.Target = targetContext.ToCommerceEntity();
basketQuery.SearchCriteria = result;
// add the line item query
var lineItemQuery = new CommerceQueryRelatedItem<CommerceEntities.LineItem>(CommerceEntities.Basket.RelationshipName.LineItems);
var itemDiscountsQuery = new CommerceQueryRelatedItem<CommerceEntities.Discount>(CommerceEntities.LineItem.RelationshipName.ItemLevelDiscounts);
var basketDiscountsQuery = new CommerceQueryRelatedItem<CommerceEntities.Discount>(CommerceEntities.LineItem.RelationshipName.BasketLevelDiscounts);
lineItemQuery.RelatedOperations.Add(basketDiscountsQuery);
lineItemQuery.RelatedOperations.Add(itemDiscountsQuery);
basketQuery.RelatedOperations.Add(lineItemQuery);
var promoCodesQuery = new CommerceQueryRelatedItem<CommerceEntities.RequestedPromoCode>(CommerceEntities.Basket.RelationshipName.RequestedPromoCodes);
basketQuery.RelatedOperations.Add(promoCodesQuery);
任何人都可以告诉我们我们得到的回复以及如何访问Itemlevel来自上述查询的篮子级别折扣
Can any one please let me know the response we get and how to access the Itemlevel and Basket level discounts from the above query
推荐答案
这篇关于篮子商务查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!