我曾經有一個DataTable,我會用這個查詢:C#自定義對象列表 - 找對象使用SQL LIKE語句
rows = dtpc.Select("POSTCODE LIKE '" + postcodeID + "%'");
這將返回許多行,我可以再從數據表中刪除。
現在我正在使用customerobjects列表而不是數據表。
[Serializable]
public class CUSTOMEROBJECT
{
public string Rep_code { get; set; }
public string Int_rep_hou { get; set; }
public string Int_rep_key { get; set; }
public string Fullname { get; set; }
public string Custcode { get; set; }
public string Category { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string Postcode { get; set; }
public string Country { get; set; }
public string Telephone { get; set; }
public double Lat { get; set; }
public double Lng { get; set; }
public string County { get; set; }
}
如何使用類似於上面使用的LIKE語句的方式找到客戶對象的選擇?
'list.Where(W => w.Postcode.StartsWith(postcodeID)' –