本文整理汇总了C#中IOrderRepository.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderRepository.Update方法的具体用法?C# IOrderRepository.Update怎么用?C# IOrderRepository.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderRepository
的用法示例。
在下文中一共展示了IOrderRepository.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public override string Import(string catalogId, string propertySetId, ImportItem[] systemValues, ImportItem[] customValues, IRepository repository)
{
var _error = string.Empty;
_repository = (IOrderRepository)repository;
var action = GetAction(systemValues.First(x => x.Name == "Action").Value);
switch (action)
{
case ImportAction.Insert:
var addItem = InitializeItem(null, systemValues);
_repository.Add(addItem);
break;
case ImportAction.InsertAndReplace:
var itemR = systemValues.FirstOrDefault(y => y.Name == "Code");
if (itemR != null)
{
var originalItem = _repository.Jurisdictions.Where(x => x.Code == itemR.Value).SingleOrDefault();
if (originalItem != null)
_repository.Remove(originalItem);
}
var replaceItem = InitializeItem(null, systemValues);
_repository.Add(replaceItem);
break;
case ImportAction.Update:
var itemU = systemValues.FirstOrDefault(y => y.Name == "Code");
if (itemU != null)
{
var origItem = _repository.Jurisdictions.Where(x => x.Code == itemU.Value).SingleOrDefault();
if (origItem != null)
{
InitializeItem(origItem, systemValues);
_repository.Update(origItem);
}
}
break;
case ImportAction.Delete:
var itemD = systemValues.FirstOrDefault(y => y.Name == "Code");
if (itemD != null)
{
var deleteItem = _repository.Jurisdictions.Where(x => x.Code == itemD.Value).SingleOrDefault();
if (deleteItem != null)
_repository.Remove(deleteItem);
}
break;
}
return _error;
}
示例2: TestSet_Batch
public void TestSet_Batch() {
//清空
_orderRepository.Clear();
//常量定义
Guid? orderId = Sys.Guid;
Guid? itemId = new Guid( "59BBE3D4-53C2-468F-AA11-3F9ED2C3A33A" );
Guid? itemId2 = new Guid( "CACC3EF1-1C8A-4948-BF78-646D826B1BCA" );
Guid? itemId3 = new Guid( "31EFBD08-3E57-4E82-BF3A-FE979B915972" );
//初始化订单并添加
var order = CreateOrder( orderId, itemId, itemId2 );
_orderRepository.Add( order );
//构造新订单,item1被删除,item2被修改,item3被新增
_order = CreateOrder( orderId, itemId2, itemId3 );
_order.Name = "order2";
//更新订单
_orderRepository = Ioc.Create<IOrderRepository>();
var context = _orderRepository.GetUnitOfWork();
context.Start();
_orderRepository.Update( _order );
context.Commit();
//查找
_orderRepository = Ioc.Create<IOrderRepository>();
_order = _orderRepository.Find( orderId.SafeValue() );
//验证
Assert.AreEqual( "order2", _order.Name );
Assert.AreEqual( 2, _order.Items.Count );
Assert.AreEqual( "a", _order.Items.First( t => t.Id == itemId2 ).Name );
Assert.AreEqual( "b", _order.Items.First( t => t.Id == itemId3 ).Name );
}