本文整理汇总了C#中Model.List.Where方法的典型用法代码示例。如果您正苦于以下问题:C# List.Where方法的具体用法?C# List.Where怎么用?C# List.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTagSet
public static List<TagProcessResult> ProcessTagSet(List<TagSimple> tagSet)
{
var resultList = new List<TagProcessResult>();
// Spellcheck
tagSet.ForEach(t => resultList.Add(
new TagProcessResult
{
TagId = t.TagId,
TagValue = t.TagValue,
WordProcessResultList = t.TagValue.Split(' ').ToList().Select(w => ProcessWord(w, t.TagId)).ToList()
}));
var correctlySpelledTagList = resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList();
resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetTest(correctlySpelledTagList, tpr));
//// Check all tags that are 100% spelled correctly for a duplicate in provided set.
//resultList.Where(t => t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(tpr => CheckTagSetForDuplicates(correctlySpelledTagList, tpr));
//// Check all tags that are unique in the provided set of tags and are 100% spelled correctly for a duplicate in the media tag repository.
//resultList.Where(t => !t.DuplicateTagId.HasValue && t.WordProcessResultList.All(w => !w.Skip)).ToList().ForEach(CheckRepositoryForDuplicates);
//resultList.Where(t => !t.MediaTagId.HasValue).ToList().ForEach(t => CheckTagSetForSynonyms(correctlySpelledTagList, t));
return resultList;
}
示例2: GetByDate
public IList<Model.DJ_GroupConsumRecord> GetByDate(int year, int month, string code, int djsid, bool? IsVerified_City, bool? IsVerified_Country)
{
List<DJ_GroupConsumRecord> ListRecord = IDjgroup.GetByDate(year, month, code, djsid, IsVerified_City, IsVerified_Country).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0)
{
//加入省市县的判断
//省
if (code.Substring(2) == "0000")
{
}
else if (code.Substring(4, 2) == "00")
{
if (item.Enterprise.Area.Code.Substring(0,4) == code.Substring(0,4))
{
List.Add(item);
}
}
else
{
if (item.Enterprise.Area.Code == code)
{
List.Add(item);
}
}
}
}
return List;
}
示例3: GetStatistics
public static IEnumerable<RecordStatistic> GetStatistics(IEnumerable<RecordData> recordDatas)
{
IList<RecordStatistic> Statistics = new List<RecordStatistic>();
RecordStatistic statistic;
foreach (var record in recordDatas)
{
statistic = Statistics.Where(s => s.ResourceType == record.ResourceType && s.ResourceName == record.ResourceName).FirstOrDefault();
TimeSpan duration = record.EndTime - record.StartTime;
if (statistic == null) //尚未统计该条record
{
statistic = new RecordStatistic();
statistic.ResourceName = record.ResourceName;
statistic.ResourceType = record.ResourceType;
statistic.ResourceType = record.ResourceType;
statistic.TotalHours = duration.TotalHours;
statistic.TotalMinutes = duration.TotalMinutes;
Statistics.Add(statistic);
}
else
{
statistic.TotalHours += duration.TotalHours;
statistic.TotalMinutes += duration.TotalMinutes;
}
}
return Statistics;
}
示例4: Match
public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
{
if (!guideProgram.PreviouslyAiredTime.HasValue)
{
return false;
}
this.MatchAttempts++;
var match = episodes.Where(e => e.FirstAired == guideProgram.PreviouslyAiredTime).FirstOrDefault();
if (match != null)
{
return this.Matched(guideProgram, match);
}
return this.Unmatched(guideProgram);
}
示例5: BuildFailureMessage
private static string BuildFailureMessage(List<Build> builds)
{
var failedBuilds = builds.Where(b => !IsSuccesfullBuild(b)).ToList();
var build = builds.First();
var stringBuilder = new StringBuilder();
stringBuilder
.AppendFormat( //todo externalize this in settings
@"<img src='http://ci.innoveo.com/img/buildStates/buildFailed.png' height='16' width='16'/><strong>Failed</strong> to build {0} branch {1} with build number <a href=""{2}""><strong>{3}</strong></a>. Failed build(s) ",
build.projectName, build.branchName, build.buildStatusUrl, build.buildNumber);
stringBuilder.Append(
string.Join(", ",
failedBuilds.Select(fb => string.Format(@"<a href=""{0}""><strong>{1}</strong></a>", fb.buildStatusUrl, fb.buildName))));
return stringBuilder.ToString();
}
示例6: CalculateAbsoluteNumbers
public void CalculateAbsoluteNumbers(List<TvdbEpisode> episodes)
{
int absoluteNumber = 0;
var actualEpisodes = episodes.Where(x => x.IsSpecial == false).ToList();
actualEpisodes.Sort(new TvEpisodeComparer());
foreach (var episode in actualEpisodes)
{
if (episode.AbsoluteNumber != -99)
{
absoluteNumber = episode.AbsoluteNumber;
}
else
{
absoluteNumber++;
episode.AbsoluteNumber = absoluteNumber;
}
}
}
示例7: Load_search_result
public List<Pro_details_entity> Load_search_result(string _txt,int type,int _idcat)
{
List<Pro_details_entity> l = new List<Pro_details_entity>();
string[] arr = _txt.Split(' ');
for (int s = 0; s < arr.Length; s++)
{
if (s == 0)
{
var list = (from c in db.ESHOP_NEWS_CATs
join a in db.ESHOP_NEWs on c.NEWS_ID equals a.NEWS_ID
join b in db.ESHOP_CATEGORies on c.CAT_ID equals b.CAT_ID
where (SqlMethods.Like(a.NEWS_KEYWORD_ASCII, ClearUnicode("%" + arr[s] + "%")))
&& a.NEWS_TYPE == type && (_idcat != 0 ? (b.CAT_ID == _idcat || b.CAT_PARENT_PATH.Contains(_idcat.ToString())) : _idcat == 0)
select new { a.NEWS_ID, a.NEWS_TITLE, a.NEWS_IMAGE3, a.NEWS_PRICE1, a.NEWS_PRICE2, a.NEWS_DESC, a.NEWS_SEO_URL, a.NEWS_URL, a.NEWS_ORDER, a.NEWS_ORDER_PERIOD, a.NEWS_PUBLISHDATE, a.NEWS_FIELD3 }).Distinct().OrderByDescending(n => n.NEWS_ID).OrderByDescending(n => n.NEWS_ORDER);
foreach (var i in list)
{
Pro_details_entity pro = new Pro_details_entity();
pro.NEWS_ID = i.NEWS_ID;
pro.NEWS_TITLE = i.NEWS_TITLE;
pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
pro.NEWS_DESC = i.NEWS_DESC;
pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
pro.NEWS_URL = i.NEWS_URL;
pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
pro.NEWS_PRICE1 = Utils.CDecDef(i.NEWS_PRICE1);
pro.NEWS_PRICE2 = Utils.CDecDef(i.NEWS_PRICE2);
pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
pro.NEWS_FIELD3 = i.NEWS_FIELD3;
pro.CAT_SEO_URL = "";
l.Add(pro);
}
}
else
{
var list = l.Where(n => n.NEWS_TITLE.ToLower().Contains(arr[s].ToLower())).ToList();
if (list != null && list.Count > 0)
l = list;
}
}
return l;
}
示例8: GetDptRecord
public List<DJ_GovManageDepartment> GetDptRecord(string beginTime, string endTime, string dptname, int entid, bool? IsVerified_City, bool? IsVerified_Country)
{
List<Model.DJ_GroupConsumRecord> ListRecord = IDjgroup.GetDptRecordByCondition(beginTime, endTime, dptname, entid, IsVerified_City, IsVerified_Country).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0)
{
List.Add(item);
}
}
List<DJ_GovManageDepartment> ListGovDpt = new BLLDJ_GovManageDepartment().GetGovDptByName(dptname).ToList();
List<DJ_GovManageDepartment> ListGovWdpt = new List<DJ_GovManageDepartment>();
foreach (DJ_GovManageDepartment item in ListGovDpt)
{
foreach (DJ_GroupConsumRecord record in List)
{
//省
if (item.Area.Code.Substring(2) == "0000")
{
//省的暂时不做处理
}
//市
else if (item.Area.Code.Substring(4,2) == "00")
{
if (item.Area.Code.Substring(0, 4) == record.Enterprise.Area.Code.Substring(0, 4))
{
ListGovWdpt.Add(item);
break;
}
}
//县
else
{
if (item.Area.Code.Substring(0, 6) == record.Enterprise.Area.Code.Substring(0, 6))
{
ListGovWdpt.Add(item);
break;
}
}
}
}
return ListGovWdpt;
}
示例9: GetDJStaticsEnt
/// <summary>
/// 地接社其他企业统计信息
/// </summary>
/// <param name="dateyear">查询年份</param>
/// <param name="EntName">查询企业名称</param>
/// <param name="EntId">所在地接社id</param>
/// <returns>查询出的企业列表</returns>
public IList<DJ_TourEnterprise> GetDJStaticsEnt(string bengintime, string endtime, string EntName, int type, int EntId, bool? IsVerified_City, bool? IsVerified_Country)
{
List<DJ_GroupConsumRecord> ListRecord = GetRecordByCondition(bengintime, endtime, EntName, type, EntId, IsVerified_City, IsVerified_Country).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x=>x.Enterprise.Id==item.Enterprise.Id).Count() == 0)
{
List.Add(item);
}
}
List<DJ_TourEnterprise> ListTE = new List<DJ_TourEnterprise>();
foreach (IGrouping<DJ_TourEnterprise, DJ_GroupConsumRecord> item in List.GroupBy(x => x.Enterprise).ToList())
{
ListTE.Add(item.Key);
}
return ListTE;
}
示例10: GetDetailDptCount
public void GetDetailDptCount(string beginTime, string endTime, string code, int entid, out int people, out int room, out int appendbed, out int visited, bool? IsVerified_City, bool? IsVerified_Country)
{
people = room = appendbed = visited = 0;
List<Model.DJ_GroupConsumRecord> ListRecord = IDjgroup.GetDptRecordByCondition(beginTime, endTime, "", entid,IsVerified_City,IsVerified_Country).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0)
{
List.Add(item);
}
}
if (code.Substring(2) == "0000")
{
//省的不会出现
}
else if (code.Substring(4, 2) == "00")
{
foreach (DJ_GroupConsumRecord item in List.Where(x => x.Enterprise.Area.Code.Substring(0, 4) == code.Substring(0, 4)))
{
if (item.Enterprise.Type==EnterpriseType.宾馆)
{
people += (item.AdultsAmount + item.ChildrenAmount) * (item.LiveDay);
room += item.RoomNum;
appendbed += item.AppendBed;
}
else if (item.Enterprise.Type == EnterpriseType.景点)
{
visited += item.AdultsAmount + item.ChildrenAmount;
}
}
}
else
{
foreach (DJ_GroupConsumRecord item in List.Where(x => x.Enterprise.Area.Code.Substring(0, 6) == code.Substring(0, 6)))
{
if (item.Enterprise.Type == EnterpriseType.宾馆)
{
people += (item.AdultsAmount + item.ChildrenAmount) * (item.LiveDay);
room += item.RoomNum;
appendbed += item.AppendBed;
}
else if (item.Enterprise.Type == EnterpriseType.景点)
{
visited += item.AdultsAmount + item.ChildrenAmount;
}
}
}
}
示例11: GetCountByStatics
public void GetCountByStatics(string begintime, string endtime, string EntName, int type, int EntId, int Enttype, int Wentid,out int people,out int room,out int appendbed)
{
people = room = appendbed = 0;
List<DJ_GroupConsumRecord> ListRecord = GetRecordByCondition(begintime, endtime, EntName, type, EntId,null,null).ToList();
//过滤掉有相同团队的记录
List<DJ_GroupConsumRecord> List = new List<DJ_GroupConsumRecord>();
foreach (DJ_GroupConsumRecord item in ListRecord)
{
if (List.Where(x => x.Route.DJ_TourGroup.Id == item.Route.DJ_TourGroup.Id).Where(x => x.ConsumeTime.ToShortDateString() == item.ConsumeTime.ToShortDateString()).Where(x => x.Enterprise.Id == item.Enterprise.Id).Count() == 0)
{
List.Add(item);
}
}
List = List.Where(x => x.Enterprise.Id == Wentid).ToList();
if (Enttype == 1)
{
foreach (DJ_GroupConsumRecord item in List)
{
people += item.AdultsAmount + item.ChildrenAmount;
}
}
if (Enttype == 4)
{
foreach (DJ_GroupConsumRecord item in List)
{
people += (item.AdultsAmount + item.ChildrenAmount)*item.LiveDay;
room += item.RoomNum;
appendbed += item.AppendBed;
}
}
}
示例12: generatePo
/// <summary>
/// GeneratePo
/// </summary>
/// <param name="proposePoList">proposePoList(EmpID, EstDate, ItemID, supplier1Qty, supplier2Qty, supplier3Qty)</param>
/// <returns></returns>
public bool generatePo(List<ProposePo> proposePoList)
{
bool result = true;
//filter the proposePoList by supplier
List<ProposePo> supplier1 = proposePoList.Where(x => x.supplier1Qty != 0).ToList();
List<ProposePo> supplier2 = proposePoList.Where(x => x.supplier2Qty != 0).ToList();
List<ProposePo> supplier3 = proposePoList.Where(x => x.supplier3Qty != 0).ToList();
//obtain supplier1 ID
string supplier1ID = ctx.Supplier.Where(x => x.Rank == 1).First().SupplierID;
//obtain supplier2 ID
string supplier2ID = ctx.Supplier.Where(x => x.Rank == 2).First().SupplierID;
//obtain supplier3 ID
string supplier3ID = ctx.Supplier.Where(x => x.Rank == 3).First().SupplierID;
//generate po for supplier 1
if (supplier1.FirstOrDefault() != null)
{
//create and add new po to db
PurchaseOrder po = new PurchaseOrder();
po.SupplierID = supplier1ID;
po.EmpID = supplier1.First().EmpID;
po.Date = DateTime.Now;
po.EstDate = Convert.ToDateTime(supplier1.First().EstDate).Date;
po.Status = "PENDING";
ctx.PurchaseOrder.Add(po);
ctx.SaveChanges();
//obtain the PoID of the newly added Po
int empID = supplier1.First().EmpID;
var poLast = ctx.PurchaseOrder.Where(x=> x.EmpID == empID).ToList().Last();
int poLastID = poLast.PoID;
double totalamt = 0;
//create and add poDetail to db
foreach (ProposePo proposepo in supplier1)
{
ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault();
PurchaseOrderDetail poDetail = new PurchaseOrderDetail();
poDetail.PoID = poLastID;
poDetail.ItemID = proposepo.ItemID;
poDetail.Qty = proposepo.supplier1Qty;
poDetail.Price = itemprice.Price;
ctx.PurchaseOrderDetail.Add(poDetail);
totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price;
}
//Update the po total amount
poLast.TotalAmt = totalamt;
}
//generate po for supplier 2
if (supplier2.FirstOrDefault() != null)
{
//create and add new po to db
PurchaseOrder po = new PurchaseOrder();
po.SupplierID = supplier2ID;
po.EmpID = supplier2.First().EmpID;
po.Date = DateTime.Now;
po.EstDate = Convert.ToDateTime(supplier2.First().EstDate);
po.Status = "PENDING";
ctx.PurchaseOrder.Add(po);
ctx.SaveChanges();
//obtain the PoID of the newly added Po
int empID = supplier2.First().EmpID;
var poLast = ctx.PurchaseOrder.Where(x => x.EmpID == empID).ToList().Last();
int poLastID = poLast.PoID;
double totalamt = 0;
//create and add poDetail to db
foreach (ProposePo proposepo in supplier2)
{
ItemPrice itemprice = ctx.ItemPrice.Where(x => x.ItemID == proposepo.ItemID && x.SupplierID == supplier1ID).FirstOrDefault();
PurchaseOrderDetail poDetail = new PurchaseOrderDetail();
poDetail.PoID = poLastID;
poDetail.ItemID = proposepo.ItemID;
poDetail.Qty = proposepo.supplier2Qty;
poDetail.Price = itemprice.Price;
ctx.PurchaseOrderDetail.Add(poDetail);
totalamt += Convert.ToDouble(poDetail.Qty) * (double)poDetail.Price;
}
//Update the po total amount
poLast.TotalAmt = totalamt;
}
//generate po for supplier 3
if (supplier3.FirstOrDefault() != null)
{
//.........这里部分代码省略.........
示例13: GetMarketList
private List<SelectListItem> GetMarketList(string selected, bool allOption = false)
{
List<SelectListItem> listeMarket = new List<SelectListItem>();
SelectListItem mAll = new SelectListItem();
SelectListItem mHealth = new SelectListItem();
SelectListItem mAdvertising = new SelectListItem();
SelectListItem mFinance = new SelectListItem();
SelectListItem mICT = new SelectListItem();
if (allOption)
{
mAll.Value = "";
mAll.Text = "All";
listeMarket.Add(mAll);
mAll.Selected = true;
}
// mAll.Selected = true;
mHealth.Value = "Health";
mHealth.Text = "Health";
mAdvertising.Value = "Advertising";
mAdvertising.Text = "Advertising";
mFinance.Value = "Finance";
mFinance.Text = "Finance";
mICT.Value = "ICT";
mICT.Text = "ICT";
listeMarket.Add(mAdvertising);
listeMarket.Add(mHealth);
listeMarket.Add(mFinance);
listeMarket.Add(mICT);
if (!string.IsNullOrEmpty(selected))
{
var selecteditem = listeMarket.Where(m => m.Value.ToLower().Equals(selected.ToLower())).FirstOrDefault();
if (selecteditem != null)
{
selecteditem.Selected = true;
}
}
return listeMarket;
}
示例14: GetSeriesByName
/// <summary>
/// Gets all series that match with the provided name.
/// </summary>
/// <param name="name">Name of the series.</param>
/// <param name="languageAbbreviation">Abbreviation of the language to search the series.</param>
/// <param name="mirror">The mirror to use.</param>
/// <returns>List of series that matches the provided name.</returns>
/// <example>Shows how to get a series by name.
/// <code>
/// namespace Docunamespace
/// {
/// /// <summary>
/// /// Class for the docu.
/// /// </summary>
/// class DocuClass
/// {
/// /// <summary>
/// /// Gets series by name.
/// /// </summary>
/// public List<Series> GetSeries(string name, Mirror mirror, Language language)
/// {
/// string apiKey = "ABCD12345";
/// TVDB.Web.ITvDb instance = new TVDB.Web.WebInterface(apiKey);
/// List<Series> series = await instance.GetSeriesByName(name, language.Abbreviation, mirror);
///
/// return series;
/// }
/// }
/// }
/// </code>
/// </example>
public async Task<List<Series>> GetSeriesByName(string name, string languageAbbreviation, Mirror mirror)
{
if (string.IsNullOrEmpty(name))
{
return null;
}
if (mirror == null)
{
return null;
}
if (string.IsNullOrEmpty(languageAbbreviation))
{
return null;
}
string url = "{0}/api/GetSeries.php?seriesname={1}&language={2}";
byte[] result = await this.client.DownloadDataTaskAsync(string.Format(url, mirror.Address, name, languageAbbreviation)).ConfigureAwait(continueOnCapturedContext: false);
MemoryStream resultStream = new MemoryStream(result);
XmlDocument doc = new XmlDocument();
doc.Load(resultStream);
XmlNode dataNode = doc.ChildNodes[1];
List<Series> series = new List<Series>();
foreach (XmlNode currentNode in dataNode.ChildNodes)
{
Series deserialized = new Series();
deserialized.Deserialize(currentNode);
series.Add(deserialized);
}
return series.Where(x => x.Language.Equals(languageAbbreviation)).ToList<Series>();
}
示例15: CheckTagSetForDuplicates
private static void CheckTagSetForDuplicates(List<TagProcessResult> tagList, TagProcessResult tpr)
{
var duplicateTagId =
tagList.Where(t => t.TagId != tpr.TagId)
.Where(t => !t.DuplicateTagId.HasValue)
.Where(t => t.TagValue.ToLower() == tpr.TagValue.ToLower())
.Select(t => t.TagId).FirstOrDefault();
if (duplicateTagId != default(int))
{
tpr.DuplicateTagId = duplicateTagId;
}
}