本文整理汇总了C#中VirtoCommerce.Domain.Catalog.Model.Select方法的典型用法代码示例。如果您正苦于以下问题:C# VirtoCommerce.Domain.Catalog.Model.Select方法的具体用法?C# VirtoCommerce.Domain.Catalog.Model.Select怎么用?C# VirtoCommerce.Domain.Catalog.Model.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtoCommerce.Domain.Catalog.Model
的用法示例。
在下文中一共展示了VirtoCommerce.Domain.Catalog.Model.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create(coreModel.Category[] categories)
{
if (categories == null)
throw new ArgumentNullException("categories");
var pkMap = new PrimaryKeyResolvingMap();
var dbCategories = categories.Select(x => x.ToDataModel(pkMap));
using (var repository = _catalogRepositoryFactory())
{
foreach (var dbCategory in dbCategories)
{
repository.Add(dbCategory);
}
CommitChanges(repository);
pkMap.ResolvePrimaryKeys();
}
//Need add seo separately
_commerceService.UpsertSeoForObjects(categories);
}
示例2: Update
public void Update(coreModel.CatalogProduct[] items)
{
var now = DateTime.UtcNow;
using (var repository = _catalogRepositoryFactory())
using (var changeTracker = base.GetChangeTracker(repository))
{
var dbItems = repository.GetItemByIds(items.Select(x => x.Id).ToArray(), coreModel.ItemResponseGroup.ItemLarge);
foreach (var dbItem in dbItems)
{
var item = items.FirstOrDefault(x => x.Id == dbItem.Id);
if (item != null)
{
//Need skip inherited properties without overridden value
if (dbItem.ParentId != null && item.PropertyValues != null)
{
var dbParentItem = repository.GetItemByIds(new[] { dbItem.ParentId }, coreModel.ItemResponseGroup.ItemProperties).First();
item.MainProduct = dbParentItem.ToCoreModel(new coreModel.Catalog { Id = dbItem.CatalogId }, new coreModel.Category { Id = dbItem.CategoryId }, null);
}
changeTracker.Attach(dbItem);
item.Patch(dbItem);
}
//Patch seoInfo
if (item.SeoInfos != null)
{
foreach (var seoInfo in item.SeoInfos)
{
seoInfo.ObjectId = item.Id;
seoInfo.ObjectType = typeof(coreModel.CatalogProduct).Name;
}
var seoInfos = new ObservableCollection<SeoInfo>(_commerceService.GetObjectsSeo(new[] { item.Id }));
seoInfos.ObserveCollection(x => _commerceService.UpsertSeo(x), x => _commerceService.DeleteSeo(new[] { x.Id }));
item.SeoInfos.Patch(seoInfos, (source, target) => _commerceService.UpsertSeo(source));
}
}
CommitChanges(repository);
}
}
示例3: Update
public void Update(coreModel.Property[] properties)
{
using (var repository = _catalogRepositoryFactory())
using (var changeTracker = base.GetChangeTracker(repository))
{
var dbProperties = repository.GetPropertiesByIds(properties.Select(x => x.Id).ToArray());
foreach (var dbProperty in dbProperties)
{
var property = properties.FirstOrDefault(x => x.Id == dbProperty.Id);
if (property != null)
{
changeTracker.Attach(dbProperty);
var dbPropertyChanged = property.ToDataModel();
dbPropertyChanged.Patch(dbProperty);
}
}
CommitChanges(repository);
}
}
示例4: Update
public void Update(coreModel.CatalogProduct[] items)
{
var pkMap = new PrimaryKeyResolvingMap();
var now = DateTime.UtcNow;
using (var repository = _catalogRepositoryFactory())
using (var changeTracker = base.GetChangeTracker(repository))
{
var dbItems = repository.GetItemByIds(items.Select(x => x.Id).ToArray(), coreModel.ItemResponseGroup.ItemLarge);
foreach (var dbItem in dbItems)
{
var item = items.FirstOrDefault(x => x.Id == dbItem.Id);
if (item != null)
{
changeTracker.Attach(dbItem);
item.Patch(dbItem, pkMap);
}
}
CommitChanges(repository);
pkMap.ResolvePrimaryKeys();
}
//Update seo for products
_commerceService.UpsertSeoForObjects(items);
}