本文整理汇总了C#中IOrderedEnumerable.Where方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderedEnumerable.Where方法的具体用法?C# IOrderedEnumerable.Where怎么用?C# IOrderedEnumerable.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderedEnumerable
的用法示例。
在下文中一共展示了IOrderedEnumerable.Where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTotalInventory
/// <summary>
/// Get Total list of items in the inventory
/// </summary>
/// <param name="lstTotalInventoryMl"></param>
/// <param name="lstInventoryMl"></param>
private List<InventoryModel> GetTotalInventory(IOrderedEnumerable<InventoryModel> lstTotalInventoryMl, string logicalDeviceId, string searchText)
{
List<InventoryModel> lstInventoryMl = new List<InventoryModel>();
var lstInventoryInMl =
lstTotalInventoryMl.Where(x => x.CurrentState.Equals(Enums.CurrentState.Add.ToString())).ToList();
var lstInventoryOutMl =
lstTotalInventoryMl.Where(x => x.CurrentState.Equals(Enums.CurrentState.Remove.ToString())).ToList();
foreach (var inventoryInMl in lstInventoryInMl)
{
var inventoryOutMl =
lstInventoryOutMl.Where(
x => x.LogicalDeviceId == inventoryInMl.LogicalDeviceId && x.TagEPC == inventoryInMl.TagEPC)
.ToList();
if (inventoryOutMl.Count == 0)
{
lstInventoryMl.Add(inventoryInMl);
}
else
{
lstInventoryOutMl.Remove(inventoryOutMl.FirstOrDefault());
}
}
lstInventoryMl.ToList().ForEach(x =>
{
x.Batch = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.Batch).FirstOrDefault();
x.ItemId = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.ItemId).FirstOrDefault();
x.Material = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.Material).FirstOrDefault();
x.ExpirationDate = (from u in ObjTersoDataContext.items
where u.EPC == x.TagEPC
select u.ExpirationDate).FirstOrDefault();
x.ExpirationDateString = x.ExpirationDate != null ? String.Format("{0:MM/dd/yyyy}", x.ExpirationDate.Value) : string.Empty;
x.DeviceId = (from u in ObjTersoDataContext.devices
where u.LogicalDeviceId == x.LogicalDeviceId
select u.DeviceId).FirstOrDefault();
});
lstInventoryMl = lstInventoryMl.Where(x => (string.IsNullOrEmpty(logicalDeviceId) || x.LogicalDeviceId.Equals(logicalDeviceId))
&& (string.IsNullOrEmpty(searchText) ||
(!string.IsNullOrEmpty(x.Material) && x.Material.Contains(searchText)) ||
(!string.IsNullOrEmpty(x.Batch) && x.Batch.Contains(searchText)) ||
x.TagEPC.Contains(searchText) || x.LogicalDeviceId.Equals(searchText)
)).ToList();
lstInventoryMl.ToList().ForEach(x =>
{
x.TotalRows = lstInventoryMl.Count;
});
return lstInventoryMl.ToList();
}
示例2: AbsentEventCreation
private static bool AbsentEventCreation(TimeBox sender, Term absent, IOrderedEnumerable<Term> orderedTerms)
{
if (orderedTerms.Any(t => t.CanNotOverlapWithAbsent && t.OverlapNotEnclosed(absent)))
return false;
var exists = orderedTerms.Where(absent.NeedRelyOn)
.Any(t =>
{
if (t.EnclosedWithTypeVerification(absent))
{
absent.Bottom = t.GetLowestTerm() as Term;
//if (absent.IsNeedSeat != t.IsNeedSeat && t is AssignmentBase)
// ((AssignmentBase)t).CancelSeatArrangement(absent);
return true;
}
return false;
});
return exists;
}
示例3: IsTeamUnderEffect
private bool IsTeamUnderEffect(
IOrderedEnumerable<Tuple<PlayCardEvent, Card>> cardsPlayedOnTeam,
EffectCardType effect)
{
var lastEffectCard = cardsPlayedOnTeam
.Where(x => x.Item2.EffectType.HasFlag(effect))
.FirstOrDefault();
if (lastEffectCard == null)
{
return false;
}
else
{
bool isUnderEffect;
switch (lastEffectCard.Item2.CardType)
{
case CardType.EFFECT_NEGATIVE:
{
isUnderEffect = true;
break;
}
case CardType.VALUE:
case CardType.EFFECT_POSITIVE:
case CardType.EFFECT_INVINCIBLE:
default:
{
isUnderEffect = false;
break;
}
}
if (effect == EffectCardType.TRAFFIC_LIGHT)
{
return !isUnderEffect;
}
return isUnderEffect;
}
}
示例4: CreateSuitesXElementWithParameters
public XElement CreateSuitesXElementWithParameters(
IOrderedEnumerable<ITestSuite> suites,
IOrderedEnumerable<ITestScenario> scenarios,
IOrderedEnumerable<ITestResult> testResults,
IXMLElementsStruct xmlStruct)
{
var suitesElement =
new XElement(xmlStruct.SuitesNode,
from suite in suites
select new XElement(xmlStruct.SuiteNode,
new XAttribute("uniqueId", suite.UniqueId),
new XAttribute("id", suite.Id),
new XAttribute("name", suite.Name),
new XAttribute("status", suite.Status),
createXattribute(xmlStruct.TimeSpentAttribute, Convert.ToInt32(suite.Statistics.TimeSpent)),
new XAttribute("all", suite.Statistics.All.ToString()),
new XAttribute("passed", suite.Statistics.Passed.ToString()),
createXattribute(xmlStruct.FailedAttribute, suite.Statistics.Failed.ToString()),
new XAttribute("notTested", suite.Statistics.NotTested.ToString()),
new XAttribute("knownIssue", suite.Statistics.PassedButWithBadSmell.ToString()),
createXattribute("description", suite.Description),
createXattribute("platformId", suite.PlatformId),
createXattribute("platformUniqueId", suite.PlatformUniqueId),
CreateScenariosXElementCommon(
suite,
// 20141122
// scenarios.Where(scenario => scenario.SuiteId == suite.Id).OrderBy(scenario => scenario.Id),
// testResults.Where(testResult => testResult.SuiteId == suite.Id).OrderBy(testResult => testResult.Id),
scenarios.Where(scenario => scenario.SuiteId == suite.Id && scenario.SuiteUniqueId == suite.UniqueId).OrderBy(scenario => scenario.Id),
testResults.Where(testResult => testResult.SuiteId == suite.Id && testResult.SuiteUniqueId == suite.UniqueId).OrderBy(testResult => testResult.Id),
xmlStruct)
)
);
return suitesElement;
}
示例5: CreateScenariosXElementCommon
public XElement CreateScenariosXElementCommon(
ITestSuite suite,
IOrderedEnumerable<ITestScenario> scenarios,
IOrderedEnumerable<ITestResult> testResults,
IXMLElementsStruct xmlStruct)
{
var testScenariosFiltered =
from scenario in scenarios
where scenario.SuiteId == suite.Id && scenario.PlatformUniqueId == suite.PlatformUniqueId
select scenario;
if (!testScenariosFiltered.Any()) {
return null;
}
var scenariosElement =
new XElement(xmlStruct.ScenariosNode,
from scenario in testScenariosFiltered
select getScenariosXElement(
suite,
scenario,
// 20141122
// testResults.Where(testResult => testResult.SuiteId == suite.Id && testResult.ScenarioId == scenario.Id).OrderBy(testResult => testResult.Id),
testResults.Where(
testResult => testResult.SuiteId == suite.Id &&
testResult.SuiteUniqueId == suite.UniqueId &&
testResult.ScenarioId == scenario.Id &&
testResult.ScenarioUniqueId == scenario.UniqueId).OrderBy(testResult => testResult.Id),
xmlStruct)
);
return scenariosElement;
}
示例6: GetFlawlessVictory
private void GetFlawlessVictory(IOrderedEnumerable<Match> matches, List<string> winners, List<string> loosers)
{
var orderedMatches = matches.Where(m=>m.PlayerList.Count == 4).OrderByDescending(m => m.TimeStampUtc).ToList();
foreach (var match in orderedMatches)
{
if(match.MatchResult.Team1Score == 0 )
{
winners.AddRange(match.PlayerList.GetRange(2, 2));
loosers.AddRange(match.PlayerList.GetRange(0, 2));
return;
}
else if (match.MatchResult.Team2Score == 0)
{
winners.AddRange(match.PlayerList.GetRange(0, 2));
loosers.AddRange(match.PlayerList.GetRange(2, 2));
return;
}
}
}