本文整理汇总了C#中GenericRepository.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# GenericRepository.GetItems方法的具体用法?C# GenericRepository.GetItems怎么用?C# GenericRepository.GetItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericRepository
的用法示例。
在下文中一共展示了GenericRepository.GetItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetArmyList
public REF_ArmyList[] GetArmyList(string state = "E")
{
using (var dataContext = new AusterlitzDbContext())
{
var listRepository = new GenericRepository<REF_ArmyList>(dataContext);
IEnumerable<REF_ArmyList> armyList = listRepository
.GetItems(x => x.State == state)
.OrderBy(y => y.ItemNo);
return armyList.ToArray();
}
}
示例2: getTRFullTurnDetails
public TurnReport getTRFullTurnDetails(string turnId)
{
using (var dataContext = new AusterlitzDbContext())
{
var turnReport = new TurnReport();
var turnCommanders = new GenericRepository<TR_Commanders>(dataContext);
turnReport.Commanders = turnCommanders.GetItems(x => x.TurnId == turnId).ToArray();
var turnBrigades = new GenericRepository<TR_Brigades>(dataContext);
turnReport.Brigades = turnBrigades.GetItems(x => x.TurnId == turnId).ToArray();
var turnWarships = new GenericRepository<TR_Warships>(dataContext);
turnReport.Warships = turnWarships.GetItems(x => x.TurnId == turnId).ToArray();
var turnMerchantShips = new GenericRepository<TR_MerchantShips>(dataContext);
turnReport.MerchantShips = turnMerchantShips.GetItems(x => x.TurnId == turnId).ToArray();
var turnBaggageTrains = new GenericRepository<TR_BaggageTrains>(dataContext);
turnReport.BaggageTrains = turnBaggageTrains.GetItems(x => x.TurnId == turnId).ToArray();
var turnSpies = new GenericRepository<TR_Spies>(dataContext);
turnReport.Spies = turnSpies.GetItems(x => x.TurnId == turnId).ToArray();
var turnStateRelationships = new GenericRepository<TR_StateRelationships>(dataContext);
turnReport.StateRelationships = turnStateRelationships.GetItems(x => x.TurnId == turnId).ToArray();
var turnWarehouses = new GenericRepository<TR_Warehouses>(dataContext);
turnReport.Warehouses = turnWarehouses.GetItems(x => x.TurnId == turnId).ToArray();
var turnBarracks = new GenericRepository<TR_Barracks>(dataContext);
turnReport.Barracks = turnBarracks.GetItems(x => x.TurnId == turnId).ToArray();
var turnTradingPortsAndCities = new GenericRepository<TR_TradingPortsAndCities>(dataContext);
turnReport.TradingPortsAndCities = turnTradingPortsAndCities.GetItems(x => x.TurnId == turnId).ToArray();
List<MovementItems> movementItems = turnReport.Commanders.Select(x => new MovementItems() { ItemNo = x.ItemNo, ItemType = ItemType.Commander, MP = x.MP, X = x.X, Y = x.Y }).ToList();
var dummy = 0;
movementItems.AddRange(turnReport.Brigades.Select(x =>
new MovementItems()
{ ItemNo = x.ItemNo, ItemType = ItemType.Brigade, MP = x.MP
, X = Int32.TryParse(x.X_OrState, out dummy) ? int.Parse(x.X_OrState) : 0
, Y = Int32.TryParse(x.Y_OrFleet, out dummy) ? int.Parse(x.Y_OrFleet) : 0
}).ToList());
// can add more union stuff here if necessary, not sure it makes much difference
movementItems.AddRange(turnReport.Warships.Select(x => new MovementItems() { ItemNo = x.ItemNo, ItemType = ItemType.Warship, MP = x.MP, X = x.X, Y = x.Y }).ToList());
movementItems.AddRange(turnReport.MerchantShips.Select(x => new MovementItems() { ItemNo = x.ItemNo, ItemType = ItemType.MerchantShip, MP = x.MP, X = x.X, Y = x.Y }).ToList());
movementItems.AddRange(turnReport.BaggageTrains.Select(x => new MovementItems() { ItemNo = x.ItemNo, ItemType = ItemType.BaggageTrain, MP = x.MP, X = x.X, Y = x.Y }).ToList());
movementItems.AddRange(turnReport.Spies.Select(x => new MovementItems() { ItemNo = x.ItemNo, ItemType = ItemType.Spy, MP = 75, X = x.X, Y = x.Y }).ToList());
turnReport.MovementItemList = movementItems.ToArray();
turnReport.MapCoordinates = GetMapCoordinates(turnId);
return turnReport;
}
}
示例3: GetMapCoordinates
public DisplayCoordinate[][] GetMapCoordinates(string turnId)
{
var displayMapArray = new DisplayCoordinate[100][];
using (var dataContext = new AusterlitzDbContext())
{
var turnMap = new GenericRepository<TR_MapCoordinates>(dataContext);
var regionalMap = new GenericRepository<REF_PoliticalMapCoordinates>(dataContext);
var turnCoordinateList = turnMap.GetItems(x => x.TurnId == turnId);
var regionalCoordinateList = regionalMap.Get();
var rulesCatalogApiController = new RulesCatalogApiController();
var refProductionSites = rulesCatalogApiController.GetRefProductionSites();
for (var y = 0; y <= 99; y++)
{
displayMapArray[y] = new DisplayCoordinate[91];
for (var x = 0; x <= 90; x++)
{
var turnCoord = turnCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);
var regionalCoord = regionalCoordinateList.SingleOrDefault(a => a.X == x && a.Y == y);
if (turnCoord != null && regionalCoord != null)
{
displayMapArray[turnCoord.Y][turnCoord.X] = new DisplayCoordinate()
{
X = x,
Y = y,
TurnId = turnId,
Population = turnCoord.Population,
ProductionSite = turnCoord.ProductionSite.Replace(".",""),
State = turnCoord.State,
Bonus = regionalCoord.Bonus,
Owner = regionalCoord.Owner,
Terrain = regionalCoord.Terrain,
};
//displayMapArray[turnCoord.Y][turnCoord.X].allowableProdSites = calcAllowableProdSites(displayMapArray[turnCoord.Y][turnCoord.X], refProductionSites, state);
}
else
{
displayMapArray[y][x] = new DisplayCoordinate()
{
X = x,
Y = y,
TurnId = turnId,
Population = ".",
ProductionSite = " ",
State = " ",
Bonus = " ",
Owner = " ",
Terrain = " "
};
}
if (x == 0)
displayMapArray[y][x].Population = x.ToString();
else if (y == 0)
displayMapArray[y][x].Population = y.ToString();
}
}
return displayMapArray;
}
}