情境個人資料內有許多經歷或是學歷
某天人資部需求想撈出那些人是碩士及博士
通常資料表會這樣開
員工資料主檔
public class Staff
{
public int StaffId { get; set; }
public string Name { get; set; }
public List EducationList { get; set; }//多種學歷
}
學歷檔
public class Education
{
public int EducationId { get; set; }
public int EducationType { get; set; }//假設有另一個資料表紀錄ID的意思 碩士是6 博士是7
public string SchoolName { get; set; }
}
抓取過濾碩士博士
int[] filter = new int[] { 6, 7 };
result = result.Where(x => x.EducationList.Any(y => filter.Contains(y.EducationType))).ToList();
string[] filter = searchTxt.Split(',' , ' ');
var result = data.Where(x => temp.Any(s => x.text.Contains(s) || x.content.Contains(s))).ToList();
備注用額外Detail符合的筆數
int mIsCondition = data.Sum(x => x.detail.Where(y => y.iscondition).Count());