How to do a LIKE query with linq?

前端 未结 8 1585
予麋鹿
予麋鹿 2020-12-03 02:57

How can i perform an LIKE query within Linq?

I have the following query i would like to execute.

var results = from c in db.costumers
              w         


        
8条回答
  •  遥遥无期
    2020-12-03 03:17

    String [] obj = (from c in db.Contacts
                               where c.FirstName.StartsWith(prefixText)
                               select c.FirstName).ToArray();
                return obj;
    

    StartsWith() and EndsWith() can help you a lot here. If you want to find data in between the field, then Contains() can be used.

提交回复
热议问题