本文整理汇总了C#中Repository.InsertOnSubmit方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.InsertOnSubmit方法的具体用法?C# Repository.InsertOnSubmit怎么用?C# Repository.InsertOnSubmit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.InsertOnSubmit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CategoriesShouldBeReturnedNested
public void CategoriesShouldBeReturnedNested()
{
using (new TransactionScope())
{
var connectionStringProvider = new ConnectionStringProvider("<my connection string>");
var dataContextProvider = new DataContextProvider(connectionStringProvider);
// first insert a new graph into the database
var categoryRepository = new Repository<Category>(dataContextProvider);
// use the object graph created by the mock category repository
var root = MockRepositoryBuilder.CreateCategoryRepository().GetRootCategory();
// add the root into the real database
categoryRepository.InsertOnSubmit(root);
categoryRepository.SubmitChanges();
// try to get the root again (note we need the actual id because we don't want the real root,
// which will have a different graph of categories, from the database)
var rootFromDb = categoryRepository.GetById(root.CategoryId);
MockRepositoryBuilder.AssertCategoryGraphIsCorrect(rootFromDb);
}
}
示例2: CreateCollectionData
public static void CreateCollectionData(int locationId, int userId)
{
CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;
Repository<CollectionData> rep = new Repository<CollectionData>(dcp);
CollectionData collectionData = new CollectionData();
collectionData.LocationID = locationId;
rep.InsertOnSubmit(collectionData);
dcp.CommitChanges(userId);
}
示例3: SaveOrders
public static List<string> SaveOrders(List<OrderDO> orders, int userId)
{
List<string> savedOrderCodes = new List<string>();
using (TransactionScope tran = TransactionScopeFactory.CreateTransactionScope())
{
Repository<Order> rep = new Repository<Order>(CheckoutDataContextProvider.Instance);
foreach (var orderDO in orders)
{
string validationProblem = string.Empty;
bool isOrderValid = ValidateIncomingOrder(orderDO, ref validationProblem);
if (isOrderValid == false)
{
ElmahLogger.Warn(string.Format("{0} kaydedilemiyor. Valid değil : {1}", orderDO.Code, validationProblem));
continue;
}
Order existingOrder = rep.GetAll().FirstOrDefault(x => x.Code == orderDO.Code);
if (existingOrder != null)
{
ElmahLogger.Warn(string.Format("{0} sipariş zaten var. Atlanıyor", orderDO.Code));
savedOrderCodes.Add(existingOrder.Code);
continue;
}
Order orderToSave = MapOrderDOToOrder(orderDO);
List<OrderItem> orderItemListToSave = MapOrderItemDOListToOrderItem(orderDO.ItemList);
var defaultPackagingLocation = LocationBL.GetDefaultPackagingLocation(orderToSave.StoreID);
orderItemListToSave.ForEach(x =>
{
if (string.IsNullOrEmpty(x.ItemIdentifier) == false)
{
x.PackagingLocationID = defaultPackagingLocation.ID;
}
x.StatusCode = OrderItemStatus.LocationWaiting.ToString();
x.StatusCodeUpdateTime = DateTime.UtcNow;
});
orderToSave.OrderItems.AddRange(orderItemListToSave);
rep.InsertOnSubmit(orderToSave);
savedOrderCodes.Add(orderToSave.Code);
}
rep.DCP.CommitChanges(userId);
tran.Complete();
}
return savedOrderCodes;
}
示例4: Save
public static int Save(ColorMappingDO colorMappingDO, int userID)
{
Repository<ColorMapping> repColor = new Repository<ColorMapping>(BeymenDataContextProvider.Instance);
ColorMapping colorMapping;
if (colorMappingDO.ID == 0)
{
colorMapping = new ColorMapping();
ObjectMapper.MapObjects<ColorMappingDO, ColorMapping>(colorMappingDO, colorMapping);
repColor.InsertOnSubmit(colorMapping);
}
else
{
colorMapping = repColor.GetAll().Where(x => x.ID == colorMappingDO.ID).SingleOrDefault();
ObjectMapper.MapObjects<ColorMappingDO, ColorMapping>(colorMappingDO, colorMapping);
repColor.UpdateByIdOnSubmit(colorMapping);
}
repColor.DCP.CommitChanges(userID);
return colorMapping.ID;
}
示例5: Save
public static void Save(Store_LocationDO model, int userID)
{
Repository<Store_Location> rep = new Repository<Store_Location>(CheckoutDataContextProvider.Instance);
Store_Location dbObject;
if (model.ID == 0)
{
dbObject = new Store_Location();
Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject);
rep.InsertOnSubmit(dbObject);
}
else
{
dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault();
Mapper.Map<Store_LocationDO, Store_Location>(model, dbObject);
}
rep.DCP.CommitChanges(userID);
Mapper.Map<Store_Location, Store_LocationDO>(dbObject, model);
}
示例6: Save
public static void Save(UserLocationDO model, int userID)
{
Repository<UserLocation> rep = new Repository<UserLocation>(CheckoutDataContextProvider.Instance);
UserLocation dbObject;
if (rep.GetAll().Where(x => x.UserName == model.UserName && x.LocationID == model.LocationID).SingleOrDefault() != null)
{
throw new BusinessException("Bu kullanıcı için bu lokasyon tanımlanmış");
}
if (model.ID == 0)
{
dbObject = new UserLocation();
Mapper.Map<UserLocationDO, UserLocation>(model, dbObject);
rep.InsertOnSubmit(dbObject);
}
else
{
dbObject = rep.GetAll().Where(x => x.ID == model.ID).SingleOrDefault();
Mapper.Map<UserLocationDO, UserLocation>(model, dbObject);
}
rep.DCP.CommitChanges(userID);
Mapper.Map<UserLocation, UserLocationDO>(dbObject, model);
}
示例7: AddOrderItemToNotFoundList
public static void AddOrderItemToNotFoundList(OrderItemDO orderItemDO, int locationId, int userId)
{
CollectionDataDO collectionDataDO = CollectionDataBL.CreateCollectionDataIfNotExist(locationId, userId);
ValidateLocation(locationId, collectionDataDO.Location.ID);
CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;
OrderItemDO orderItem = CheckoutBL.GetOrderItemById(orderItemDO.ID);
if (SupplyRuleEngine.CanOrderItemBeAddedToNotFoundList(collectionDataDO, orderItem))
{
Repository<CollectionOrderItem> rep = new Repository<CollectionOrderItem>(dcp);
CollectionOrderItem collectionOrderItem = new CollectionOrderItem();
collectionOrderItem.OrderItemID = orderItemDO.ID;
collectionOrderItem.StatusCode = OrderItemStatus.NotFound.ToString();
collectionOrderItem.CollectionDataID = collectionDataDO.ID;
collectionOrderItem.NotFoundReasonID = orderItemDO.NotFoundReasonID;
rep.InsertOnSubmit(collectionOrderItem);
dcp.CommitChanges(userId);
}
}
示例8: AddOrderItemListToFoundList
public static void AddOrderItemListToFoundList(List<int> orderItemIdList, int locationId, int userId)
{
CollectionDataDO collectionDataDO = CollectionDataBL.CreateCollectionDataIfNotExist(locationId, userId);
ValidateLocation(locationId, collectionDataDO.Location.ID);
CheckoutDataContextProvider dcp = CheckoutDataContextProvider.Instance;
List<OrderItemDO> orderItemList = CheckoutBL.GetOrderItemListByIdList(orderItemIdList);
foreach (var orderItem in orderItemList)
{
if (SupplyRuleEngine.CanOrderItemBeAddedToFoundList(collectionDataDO, orderItem))
{
Repository<CollectionOrderItem> rep = new Repository<CollectionOrderItem>(dcp);
CollectionOrderItem collectionOrderItem = new CollectionOrderItem();
collectionOrderItem.OrderItemID = orderItem.ID;
collectionOrderItem.StatusCode = OrderItemStatus.Found.ToString();
collectionOrderItem.CollectionDataID = collectionDataDO.ID;
rep.InsertOnSubmit(collectionOrderItem);
}
}
dcp.CommitChanges(userId);
}