本文整理汇总了C#中IWorkspace.All方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkspace.All方法的具体用法?C# IWorkspace.All怎么用?C# IWorkspace.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.All方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePeriodicConsumptionItems
private static void CreatePeriodicConsumptionItems(PeriodicConsumption pc, IWorkspace workspace)
{
var previousPc = GetPreviousPeriodicConsumption(workspace);
var transactionItems = GetTransactionItems();
foreach (var inventoryItem in workspace.All<InventoryItem>())
{
var iItem = inventoryItem;
var pci = new PeriodicConsumptionItem { InventoryItem = inventoryItem };
pci.UnitMultiplier = pci.InventoryItem.TransactionUnitMultiplier > 0 ? pci.InventoryItem.TransactionUnitMultiplier : 1;
pc.PeriodicConsumptionItems.Add(pci);
var previousCost = 0m;
if (previousPc != null)
{
var previousPci = previousPc.PeriodicConsumptionItems.SingleOrDefault(x => x.InventoryItem.Id == iItem.Id);
if (previousPci != null) pci.InStock =
previousPci.PhysicalInventory != null
? previousPci.PhysicalInventory.GetValueOrDefault(0)
: previousPci.GetInventoryPrediction();
if (previousPci != null)
previousCost = previousPci.Cost * pci.InStock;
}
var tim = transactionItems.Where(x => x.InventoryItem.Id == iItem.Id);
pci.Purchase = tim.Sum(x => x.Quantity * x.Multiplier) / pci.UnitMultiplier;
var totalPrice = tim.Sum(x => x.Price * x.Quantity);
if (pci.InStock > 0 || pci.Purchase > 0)
{
pci.Cost = pci.InStock > 0
? decimal.Round((totalPrice + previousCost)/(pci.InStock + pci.Purchase), 2)
: decimal.Round(totalPrice/pci.Purchase, 2);
}
}
}
示例2: ImportPlainText
private static IEnumerable<Entity> ImportPlainText(string[] values, IWorkspace workspace)
{
IList<Entity> result = new List<Entity>();
if (values.Length > 0)
{
var entityTypes = workspace.All<EntityType>().ToList();
EntityType currentEntityType = null;
foreach (var value in values)
{
if (value.StartsWith("#"))
{
currentEntityType = CreateEntityType(value, entityTypes);
}
else if (currentEntityType != null)
{
var entity = CreateEntity(workspace, value, currentEntityType);
if (entity != null)
{
result.Add(entity);
}
}
}
}
return result;
}
示例3: GetTickets
private static IEnumerable<Ticket> GetTickets(IWorkspace workspace)
{
try
{
if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
return Dao.Query<Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate,
x => x.Payments, x => x.TaxServices,
x => x.Discounts, x => x.TicketItems,
x => x.TicketItems.Select(y => y.Properties));
return
Dao.Query<Ticket>(x =>
x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate,
x => x.Payments, x => x.TaxServices, x => x.Discounts, x => x.TicketItems.Select(y => y.Properties));
}
catch (SqlException)
{
if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
return workspace.All<Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate);
return
workspace.All<Ticket>(x =>
x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate);
}
}