Linq, Expressions, NHibernate and Like comparison

后端 未结 4 1788
[愿得一人]
[愿得一人] 2021-02-09 18:52

I am trying to do a like comparison based on an outside parameter (passed by a search form) that determines type of comparison (\"%string\" or \"string%\"

4条回答
  •  青春惊慌失措
    2021-02-09 19:21

    This is exactly what I had in mind, thank you. I had something similar already written, but it didn't translate to SQL. For example, it worked if I did this directly:

    Entity.StringProperty.EndsWith("SearchString");
    

    It didn't work if I used a dedicated method:

    CompMethod("BaseString","SearchString",SelectedComparsionType.EndsWith)
    

    I think it probably has something to do with expression evaluation, i'm just not sure what.

提交回复
热议问题