本文整理汇总了C#中IWorkspace.Single方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkspace.Single方法的具体用法?C# IWorkspace.Single怎么用?C# IWorkspace.Single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.Single方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenTicket
public void OpenTicket(int ticketId)
{
Debug.Assert(_workspace == null);
Debug.Assert(Ticket == null);
_workspace = WorkspaceFactory.Create();
if (LocalSettings.DatabaseLabel == "CE")
Ticket = _workspace.Single<Ticket>(ticket => ticket.Id == ticketId);
else
{
Ticket = _workspace.Single<Ticket>(ticket => ticket.Id == ticketId,
x => x.TicketItems.Select(y => y.Properties),
x => x.Payments, x => x.Discounts, x => x.TaxServices);
}
}
示例2: CreateEntity
private static Entity CreateEntity(IWorkspace workspace, string name, EntityType currentEntityType)
{
var entityName = name.ToLower().Trim();
return workspace.Single<Entity>(x => x.Name.ToLower() == entityName) != null
? null
: new Entity { Name = name, EntityTypeId = currentEntityType.Id };
}
示例3: GetCurrentPeriodicConsumption
public static PeriodicConsumption GetCurrentPeriodicConsumption(IWorkspace workspace)
{
var pc = workspace.Single<PeriodicConsumption>(x =>
x.WorkPeriodId == AppServices.MainDataContext.CurrentWorkPeriod.Id) ??
CreateNewPeriodicConsumption(workspace);
return pc;
}
示例4: LoadResourceScreenItems
public IList<ResourceScreenItem> LoadResourceScreenItems(string selectedResourceScreen)
{
if (_resoureceWorkspace != null)
{
_resoureceWorkspace.CommitChanges();
}
_resoureceWorkspace = WorkspaceFactory.Create();
return _resoureceWorkspace.Single<ResourceScreen>(x => x.Name == selectedResourceScreen).ScreenItems;
}
示例5: LoadWidgets
public IList<Widget> LoadWidgets(string selectedEntityScreen)
{
if (_resoureceWorkspace != null)
{
_resoureceWorkspace.CommitChanges();
}
_resoureceWorkspace = WorkspaceFactory.Create();
return _resoureceWorkspace.Single<EntityScreen>(x => x.Name == selectedEntityScreen).Widgets;
}
示例6: GetPreviousPeriodicConsumption
public static PeriodicConsumption GetPreviousPeriodicConsumption(IWorkspace workspace)
{
return AppServices.MainDataContext.PreviousWorkPeriod == null ? null :
workspace.Single<PeriodicConsumption>(x => x.WorkPeriodId == AppServices.MainDataContext.PreviousWorkPeriod.Id);
}
示例7: UpdateConsumption
private static void UpdateConsumption(PeriodicConsumption pc, IWorkspace workspace)
{
var sales = GetSales(AppServices.MainDataContext.CurrentWorkPeriod);
foreach (var sale in sales)
{
var lSale = sale;
var recipe = workspace.Single<Recipe>(x => x.Portion.Name == lSale.PortionName && x.Portion.MenuItemId == lSale.MenuItemId);
if (recipe != null)
{
var cost = 0m;
foreach (var recipeItem in recipe.RecipeItems.Where(x => x.InventoryItem != null && x.Quantity > 0))
{
var item = recipeItem;
var pci = pc.PeriodicConsumptionItems.Single(x => x.InventoryItem.Id == item.InventoryItem.Id);
pci.Consumption += (item.Quantity * sale.Total) / pci.UnitMultiplier;
Debug.Assert(pci.Consumption > 0);
cost += recipeItem.Quantity * (pci.Cost / pci.UnitMultiplier);
}
pc.CostItems.Add(new CostItem { Name = sale.MenuItemName, Portion = recipe.Portion, CostPrediction = cost, Quantity = sale.Total });
}
}
}
示例8: LoadTables
public IList<Table> LoadTables(string selectedTableScreen)
{
if (_tableWorkspace != null)
{
_tableWorkspace.CommitChanges();
}
_tableWorkspace = WorkspaceFactory.Create();
return _tableWorkspace.Single<TableScreen>(x => x.Name == selectedTableScreen).Tables;
}
示例9: CreateWarehouseTestContext
private static void CreateWarehouseTestContext(WarehouseTestContext testContext, IWorkspace workspace)
{
workspace.Delete<InventoryTransactionType>(x => x.Id > 0);
workspace.Delete<Entity>(x => x.Id > 0);
testContext.Iskender = workspace.Single<MenuItem>(x => x.Name == "İskender");
testContext.Iskender.Portions[0].MenuItemId = testContext.Iskender.Id;
testContext.DonerEti = new InventoryItem { Name = "Döner Eti", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 };
testContext.Yogurt = new InventoryItem { Name = "Yoğurt", BaseUnit = "GR", GroupCode = "", TransactionUnit = "KG", TransactionUnitMultiplier = 1000 };
testContext.Pide = new InventoryItem { Name = "Pide", BaseUnit = "Yarım", GroupCode = "", TransactionUnit = "Adet", TransactionUnitMultiplier = 2 };
testContext.ZeytinYagi = new InventoryItem { Name = "Zeytin Yağı", BaseUnit = "Ölçü", GroupCode = "", TransactionUnit = "Litre", TransactionUnitMultiplier = 100 };
workspace.Add(testContext.DonerEti);
workspace.Add(testContext.Yogurt);
workspace.Add(testContext.Pide);
workspace.Add(testContext.ZeytinYagi);
testContext.IskenderRecipe = new Recipe { Name = "İskender Reçetesi", Portion = testContext.Iskender.Portions[0] };
workspace.Add(testContext.IskenderRecipe);
testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.DonerEti, Quantity = 120 });
testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Yogurt, Quantity = 50 });
testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.Pide, Quantity = 2 });
testContext.IskenderRecipe.RecipeItems.Add(new RecipeItem { InventoryItem = testContext.ZeytinYagi, Quantity = 1 });
testContext.LocalWarehouseAccountType = new AccountType { Name = "Local Warehouse Account Type" };
testContext.SellerWarehouseAccountType = new AccountType { Name = "Seller Warehouse Account Type" };
workspace.Add(testContext.LocalWarehouseAccountType);
workspace.Add(testContext.SellerWarehouseAccountType);
testContext.WarehouseType = workspace.Single<WarehouseType>(x => x.Name == Resources.Warehouses);
testContext.WarehouseEntityType = new EntityType { Name = "Warehouse Resource Type" };
workspace.Add(testContext.WarehouseEntityType);
testContext.LocalWarehouseAccount = new Account { AccountTypeId = testContext.LocalWarehouseAccountType.Id };
testContext.Seller1Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id };
testContext.Seller2Account = new Account { AccountTypeId = testContext.SellerWarehouseAccountType.Id };
workspace.Add(testContext.LocalWarehouseAccount);
workspace.Add(testContext.Seller1Account);
workspace.Add(testContext.Seller2Account);
testContext.LocalWarehouse = new Warehouse
{
WarehouseTypeId = testContext.WarehouseType.Id
};
testContext.BarWarehouse = new Warehouse
{
WarehouseTypeId = testContext.WarehouseType.Id
};
testContext.Seller1Warehouse = new Warehouse
{
WarehouseTypeId = testContext.WarehouseType.Id
};
testContext.Seller2Warehouse = new Warehouse
{
WarehouseTypeId = testContext.WarehouseType.Id
};
workspace.Add(testContext.LocalWarehouse);
workspace.Add(testContext.BarWarehouse);
workspace.Add(testContext.Seller1Warehouse);
workspace.Add(testContext.Seller2Warehouse);
testContext.LocalWarehouseEntity = new Entity
{
WarehouseId = testContext.LocalWarehouse.Id,
EntityTypeId = testContext.WarehouseEntityType.Id,
AccountId = testContext.LocalWarehouseAccount.Id
};
testContext.BarWarehouseEntity = new Entity
{
WarehouseId = testContext.BarWarehouse.Id,
EntityTypeId = testContext.WarehouseEntityType.Id
};
testContext.Seller1WarehouseEntity = new Entity
{
WarehouseId = testContext.Seller1Warehouse.Id,
EntityTypeId = testContext.WarehouseEntityType.Id,
AccountId = testContext.Seller1Account.Id
};
testContext.Seller2WarehouseEntity = new Entity
{
WarehouseId = testContext.Seller2Warehouse.Id,
EntityTypeId = testContext.WarehouseEntityType.Id,
AccountId = testContext.Seller2Account.Id
};
workspace.Add(testContext.LocalWarehouseEntity);
workspace.Add(testContext.BarWarehouseEntity);
workspace.Add(testContext.Seller1WarehouseEntity);
workspace.Add(testContext.Seller2WarehouseEntity);
testContext.PurchaseAccountTransactionType = new AccountTransactionType
{
SourceAccountTypeId =
testContext.SellerWarehouseAccountType.Id,
TargetAccountTypeId =
//.........这里部分代码省略.........