c# - LINQ to Entities does not recognize the method 'System.String IfNullOrWhiteSpace' -
so, have search query giving me error now. (it didn't used too, fyi...) anyway, it's throwing "linq entities not recognize method 'system.string ifnullorwhitespace"...
is there beter way of doing this?
var stringresults = _propertyrepository .getproperties() .where( // standard fields x => x.address.ifnullorwhitespace("").contains(searchstring) || x.city.ifnullorwhitespace("").contains(searchstring) || x.websiteurl.ifnullorwhitespace("").contains(searchstring) || x.zip.ifnullorwhitespace("").contains(searchstring) // overrides possible || (x.descriptionoverride ? x.descriptionoverridevalue.contains(searchstring) : x.description.ifnullorwhitespace("").contains(searchstring)) || (x.nameoverride ? x.nameoverridevalue.contains(searchstring) : x.name.contains(searchstring)) || (x.squarefootageoverride ? x.squarefootageoverridevalue.tostring().contains(searchstring) : x.squarefootage.tostring().contains(searchstring)) // tags || (x.tagsoverride ? x.tagsoverridevalue.any(f => f.tagname.contains(searchstring)) : x.tags.any(f => f.tagname.contains(searchstring))) // bayoptions || x.bayoptions.any(g => g.baysizeoverride ? g.baysizeoverridevalue.tostring().contains(searchstring) : g.baysize.tostring().contains(searchstring)) || x.bayoptions.any(g => g.descriptionoverride ? g.descriptionoverridevalue.ifnullorwhitespace("").contains(searchstring) : g.description.ifnullorwhitespace("").contains(searchstring)) || x.bayoptions.any(g => g.excerptoverride ? g.excerptoverridevalue.ifnullorwhitespace("").contains(searchstring) : g.excerpt.ifnullorwhitespace("").tostring().contains(searchstring)) // freeform fields || x.freeformfields.any(g => g.numbervalue.tostring().contains(searchstring)) || x.freeformfields.any(g => g.stringvalue != null && g.stringvalue.tostring().contains(searchstring)) ).tolist();
ifnullorwhitespace
custom extension method, l2e provider not know it.
you don't need null checks when doing contains
in l2e, can remove ifnullorwhitespace
part.
Comments
Post a Comment