Integer Contains Using Linq

前端 未结 2 1179
长发绾君心
长发绾君心 2020-12-14 21:56

I\'m having some difficulty writing a linq query that will check whether the consecutive digits in an integer are contained in the primary key of a table. So, suppose there

相关标签:
2条回答
  • 2020-12-14 22:27

    Try:

    var results = from e in myDbContext.Employees
      where SqlFunctions.StringConvert((double)e.Id).Contains(filter)
      select e;
    
    0 讨论(0)
  • 2020-12-14 22:44

    You can convert both to string and then do the query. In your case:

    string filter = "456"; var results = from e in myDbContext.Employees where e.Id.ToString().Contains(filter) select e;

    0 讨论(0)
提交回复
热议问题