Using “Match” in a Linq statement

后端 未结 4 1377
南旧
南旧 2020-12-14 22:45

I have a table that has two records (there will be many at runtime). The deviceId of the records are, “DEVICE1” and “DEVICE2”. I want to use a regular expressio

4条回答
  •  半阙折子戏
    2020-12-14 23:31

    LinqToEntities does not support pushing Regex's down to the database. Just do Contains (which gets converted to sql... where DeviceId Like '%DEVICE%').

        filterText = @"DEVICE.";
    
    
        using (var ctx = new MyEntities())
        {
                var devices = from d in ctx.Devices
                              d.DeviceId.Contains(filterText)
    
                              select d;
                return devices.ToList();
            }
    

提交回复
热议问题