private ItemType GetItemType(string Name, UnitOfWork uow) { ItemType itemType = uow.FindObject<ItemType>(new BinaryOperator("ItemTypeName", Name)); if (itemType == null) { itemType = new ItemType(uow); itemType.ItemTypeName = Name; itemType.ItemTypeCode = Name; itemType.Save(); } return itemType; }
private ItemType GetItemType(string ItemTypeName) { if (dictItemType == null) { dictItemType = new Dictionary<string, ItemType>(); XPCollection<ItemType> itemTypes = new XPCollection<ItemType>(session); foreach (ItemType iType in itemTypes) { dictItemType.Add(iType.ItemTypeName.ToUpper(), iType); } } if (dictItemType.ContainsKey(ItemTypeName.ToUpper())) { return dictItemType[ItemTypeName.ToUpper()]; } else { ItemType itemType = new ItemType(session); itemType.ItemTypeName = ItemTypeName; itemType.Save(); dictItemType.Add(itemType.ItemTypeName.ToUpper(), itemType); return itemType; } }