問題
使用 LINQ.Contains or LINQ.StartWith 做LIKE篩選資料
解決方法
var records = from view in db.V_CUSTOMER select new { CUSTOMER_NO = view.CUSTOMER_NO, ID_NO = view.ID_NO, CUST_NAME = view.CUST_NAME, }; //LIKE寫法,取姓為'王'的客戶 records = records.Where(o => o.CUST_NAME.StartsWith("王")); //LIKE寫法,取名字內有'怡'的客戶 records = records.Where(o => o.CUST_NAME.Contains("怡"));
沒有留言:
張貼留言